Ionic cordova build removes /www directory and implicitly my .db file

Hello,
I am using ionic+cordova+angular for an app. I have a database.db file in /www and by using ionic sqlite copy plugin, i managed to copy the .db file and after that using it with ionic sqlite plugin. All works well when debugging with ionic cordova build android -l --debug.
But when i try just ionic cordova build android for building my apk, it deletes the whole /www file and i loose the .db file. The bad part is that the copy method from ionic sqlite copy plugin only wants that .db file to be in /www, i cannot give a custom reference to the file.
So, is there any way to not have the www/database.db deleted? Or do you have another idea for this issue?

Thanks!

Like node_modules, don’t manually touch anything under www. Under src/assets/ somewhere is the typical place for things like your database file.

You are to place the database in platforms/android/platform_www . This way your database gets bundled whenever you build your app and also copies it to www folder automatically. I hope this helps you. Cheers!!!

Hi, thanks for the message. I managed to solve the issue by having the .db file in /assets and having a rule in angular.json to copy all .db files from /assets into /www when the dir is created at build. But you idea seems better, i didn t knoe that platforms/android/platform_www is integrally copied into /www.
Many thanks and all the best

FWIW, I disagree. It won’t survive platform removal/readdition, and won’t work in CI or automated build environments. You should not need to be manually copying anything: put things in src/assets and they should be incorporated for you.

The problem with just having the .db file in /assets is that the sqlite db copy plugin won’t work, because it checks just /www for the .db . With any other type of file(imgs, fonts etc) i totally agree with you, but if you want to use that plugin, you need to have the .db inside /www. Angular.json has config for copy procedure, copying things from /assets to /www at build, so i just added the rule for copying .db files, alongside images fonts and other resources.

For the issue of platform removal or adding he just need to put the file back in there and it is not everytime you remove platform and add back.

You are welcome @edy1993 glad to be of help