1

Hello I'm working on an android program that uses a database. My database is going include about 300 to 400 records.

My question is what is be best way to work with the database. Should I create the database at run time via code and insert the records "manually" every time the program starts, or should I use an external database, that's located in the /assetes folder of the program?

If the second option is the way to go, could someone please give me an advice on how to do that, because I can't find any toturial that covers this subject.

Thank you!

asked Feb 23, 2011 at 1:29

2 Answers 2

2

There's another option, which is to initialize the database the first time the program is launched. See the SQLiteOpenHelper class, and especially the onCreate method in that class.

answered Feb 23, 2011 at 1:33
Sign up to request clarification or add additional context in comments.

1 Comment

To be honest this is the first time I really "touch" SQL. I've looked into a lot of guides, and didn't figured that what they did is what you said(I thought they created the table every time the program runs).
0

Here is a tutorial for the 2nd option you mentioned.

Put your db in the asset folder and if DB does not exist in /data/data/YOUR_PACKAGE/databases/, it will copy the database over.

answered Feb 23, 2011 at 3:31

1 Comment

Thanks, but I used this tutorial and for some reason it doesn't work for me, and I can't find any other guide on the web on that subject for some reason.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.