Android Question How do I refresh a SQLite database when compiling...

Robert Maguire

Member
Licensed User
Hi,

I'm working on an app (Android) with a SQLite database. I use SQLite Expert on my PC to design and modify my SQLlite database, which is stored in the 'Files' folder of my B4A project.
The first time I Compile and Run my app the SQLite database is copied over to my phone and all is good.
If I subsequently modify the SQLite database, i.e. add a table, add some columns, etc... the changed SQLite database is not copied over to my phone when I Compile and Run and obviously the app crashes.
I'm sure I'm missing something simple but my question is:

Where should I store the SQLite database on my PC when developing the app?
and/or
How do I get the updated SQLite database to move onto the phone when I Compile and Run?
Thanks in advance...
 

MarkusR

Well-Known Member
Licensed User
i guess u copied the database only once if it not exists from DirAssets (read only & used as template) to any folder at your phone.
for a new copy u need delete the database there or uninstall your app which also delete everything that belongs to the app sandbox enviroment.

or u can use "conditional compilation"
https://www.b4x.com/android/forum/threads/conditional-compilation-build-configurations.40746/

also interesting is #CustomBuildAction
https://www.b4x.com/android/forum/threads/compilation-time-and-auto-increment-build-version.64183/
 
Last edited:
Upvote 0

Robert Maguire

Member
Licensed User
Thanks Folks,

I was using CopyDBFromAssets...I just didn't think it through properly. Added the File.Delete and problem solved. Makes sense to use conditional compilation when developing.

Cheers
 
Upvote 0
Top