Robert Maguire Member Licensed User Longtime User Jan 18, 2019 #1 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...
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...
klaus Expert Licensed User Longtime User Jan 18, 2019 #2 When you first run the program where do you save the database file? You need to copy it somewhere. I use the code shown HERE. Upvote 0
When you first run the program where do you save the database file? You need to copy it somewhere. I use the code shown HERE.
MarkusR Well-Known Member Licensed User Longtime User Jan 18, 2019 #3 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: Jan 21, 2019 Upvote 0
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/
KMatle Expert Licensed User Longtime User Jan 18, 2019 #4 This is why I do not copy a db from assets. Do it by code and check if a table/column/value exists and add it. With this you have full control. Easy and precize. Upvote 0
This is why I do not copy a db from assets. Do it by code and check if a table/column/value exists and add it. With this you have full control. Easy and precize.
Robert Maguire Member Licensed User Longtime User Jan 21, 2019 #5 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
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