i need to troubleshoot errors in the Sqllite3 database that I have created in Ionic.
I have used the following command to create is
this.sqlite.create({
name: this.database_name,
location: 'default'
})
My question is how can i export this - e.g. via email
Or even better view the db via the device
Thanks fo the help team - new to Ionic
I use this in an Ionic 3 app to export the local db and upload somewhere else:
import { File, DirectoryEntry } from '@ionic-native/file';
var fileUrl = this._File.applicationStorageDirectory + "databases/<db_name_here>";
var dateString = moment().format('HH:mm:ss, ddd, DD/MM/YYYY')
.replace(/\//g, '-')
.replace(/ /g, '-')
.replace(/:/g, '-')
.replace(/,/g, '-');
var outFileName = "backup_date_" + dateString + ".db";
this._File.resolveLocalFilesystemUrl(fileUrl).then(fileEntry => {
this._File.resolveDirectoryUrl(this._File.externalDataDirectory || this._File.documentsDirectory).then(dirEntry => {
fileEntry.copyTo(dirEntry, outFileName,
(success) => {
// do something with outFileName
},
(err) => {
// do what you want with this error
}
);
}).catch(err => {
// do what you want with this error
})
}).catch(err => {
// do what you want with this error
});
Thanks for that @Daveshirman , any idea how to do that for Ionic 5 ?, I am also using Cordova
I have errors stating that applicationStorageDirectory is not a member of _File, even after declaring the Constructor
I’ve not tried it with Ionic 5.
However any error you get with the _File wrapper is down to Ionic Native wrapper, so double check you’ve installed that first.
Did you install the wrapper (and the Cordova plugin) from here: File API Plugin for Read and Write File Access on Devices
?