cordova-plugin-dbcopy
cordova-plugin-dbcopy copied to clipboard
Ionic 4 problem copy database.db
I have an app on ionic 4 with angular, with a populated bd. but when copying the BD I get error 400, if I run the app again I get error 516. I don't know what to do to make it work well. here my code
init() { this.platform.ready().then((readySource) => { console.log('Platform ready from', readySource); // Platform now ready, execute any required native code this.sqliteDbCopy.copy("database.db", 0) .then((res: any) => console.log(' t ' + res)) .catch((error: any) => console.error(error)); });
}
If I put the bd in the www folder, executing the run android command will delete the file
@an-rahulpandey Hi there, first of all thanks for a great plugin, I'm having exactly same problem as nicowxdvd, putting db file inside www folder and running ionic cordova build android / ionic cordova emulate android will remove it from www folder... Any suggestion how to work around this?
@nicowxdvd What is the full error you get when you receive error code 400? 516 means db already exists at the location. @Exerlol you can try creating a hook which can copy the db
@nicowxdvd your database file location is incorrect you have to place database in ionic android or iOS platform under www folder below are location for the same:
- Android - platforms/android/app/src/main/assets/www
- iOS - platforms/ios/www
You can copy to this particular location using config.xml resource-file tag for each platform
-
Android -
<resource-file src="dblocationinproject" target="app/src/main/assets/www/database.db" />
-
iOS -
<resource-file src="dblocationinproject" target="../../www/database.db" />
For example I can see in your screenshot your database location is: src/www/database.db