Working with Android databases

Status
Not open for further replies.
Hi,

I've decided to dip my toe into android development, I have a little bit of Java experience already. I'm currently looking into how best to use a database. Ideally I want to create the database file and then bundle it with the application. However I'm seeing in many tutorials the SQL create table commands being shoved in a class and then called when the database needs to be created.

Is there a way I can just package it and have my dbadapter class open the file rather than having it issue the create table commands all the time?

Thanks
 

Xavin

Ars Legatus Legionis
30,828
Subscriptor++
No, because you will be creating it in the users data partition where it can be written to. You don't have write access to the partition where the app actually lives. You could conceivably hack something up to copy around an already created db, but it's inadvisable. It will be a lot easier and a lot more maintainable to just do a proper SQL table creation script.
 
Edit: I've thrown some code together from a few tutorials, most stuff is working ok but I'm getting a null pointer when attempting to insert a new record. Instead of posting the whole lot here, I've made a question on stackoverflow if anyone has a moment to take a look, thanks.

http://stackoverflow.com/questions/3860 ... on-android

Fixed, helps when I open the db connection first :rolleyes:
 
Status
Not open for further replies.