SQLLite architecture question

gmlogan

Member
Licensed User
Longtime User
Hi
Can somebody give me an overview for SQLLite in terms of how it integrate into the dev model? Specifically
1) Can I package a DB file with the app code, rather than always creating it in the code itself?
2) Assuming 1 above, any recommendations for tools to manage a DB File outside the IDE?

The use case is I want to include a database of several 100's of name, value pairs (likely to become more complex over time), the user can search etc and the values get used in calculations. User will be able to do basic CRUD activities but ontop of the pre-populated data.

Thanks, Graham
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1) You can add a database if it is not too large (less than 3-4mb).
2) There are several tools that support SQLite. Maybe someone else can recommend you, I don't have enough experience with anyone.
You will not be able to open the database when it is stored in the assets folder. You will need to first copy it to the storage card or internal storage.
 
Upvote 0

glook

Member
Licensed User
Longtime User
2) Assuming 1 above, any recommendations for tools to manage a DB File outside the IDE?

I do all the database management on the desktop, before they are transfered to wherever needed.

There are several tools around, but I usually use the SQLite Manager Add-on for Firefox - it is pretty capable and very convienient, being just a click away on the browser "Tools" menu. It's free to use, just search in the Firefox add-ons page.
 
Upvote 0

asawyer13

Member
Licensed User
Longtime User
If you include the database with the original APK, then place your app on the Android Marketplace, someone downloads and installs the app, then later you change the app and update the Marketplace. When the user downloads the new application, will the db file be overwritten?

Alan
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you include the database with the original APK, then place your app on the Android Marketplace, someone downloads and installs the app, then later you change the app and update the Marketplace. When the user downloads the new application, will the db file be overwritten?
Files included in the APK are read-only. Therefore you need to first copy the database from the APK file when your program starts. There are several examples of this in the forum.
Assuming that you first check if the file exists and only if not you copy the database from the APK file, then it will work properly when the user installs a new update.
 
Upvote 0

CidTek

Active Member
Licensed User
Longtime User
Files included in the APK are read-only. Therefore you need to first copy the database from the APK file when your program starts. There are several examples of this in the forum.
Assuming that you first check if the file exists and only if not you copy the database from the APK file, then it will work properly when the user installs a new update.

What if new database data is part of the update - how would you overwrite the database on update installs?
 
Upvote 0

asawyer13

Member
Licensed User
Longtime User
If you wanted to overwrite the database, I would have the part of the program that checks to see if it needs to copy the database file just check the database, and I'd have something in the database that says to overwrite it..

You could also add code to the program to alter the existing database if the structure changed so that the old database wouldn't have to be destroyed.

Alan
 
Upvote 0
Top