I'm new to android application development. I'm on course of developing my first app which displays the time table of the selected class/faculty on the selected day(Mon,Tue etc.,). I'm all done with UI. Now my problem is how & where to write the code for the entire database insertion (as it should be loaded from the beginning). Can any one help me with this in a detailed manner as i'm new to this field ?
-
inserting table, editing and other done in your database as like.. To read you need to write web-service and that can be read through asset folder of your application. – arshad kr Aug 30 '12 at 13:03
-
Read this post for using SQlite in android http://mfarhan133.wordpress.com/2010/10/24/database-crud-tutorial-for-android/ – Akshay Aug 30 '12 at 13:04
-
http://stackoverflow.com/questions/9109438/how-to-use-existing-database-with-android-app/9109728#9109728 – Yaqub Ahmad Aug 30 '12 at 16:35
2 Answers
The general steps for what you are looking to do are as follows:
1) Create/convert your database to SQLite (the db used by Android)
2) Put the database in your assests
folder
3) Write code to copy the DB from your assets folder to the private databases folder for your app when it runs for the first time.
4) Write code to access the database as necessary once the DB is in the private folder.
A tutorial for using/importing an existing SQLite database in your app can be found at http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
There are many tutorials for creating a database helper class (to handle Creation, Reading, Updating and Deleting functions). A good one I've used and recommended before can be found at http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/

- 16,318
- 9
- 52
- 84
I think what you need is to ship your database with your apk. You, however, will need to move the database file, because the system expects its databases to be in the private storage. You can see how this is done here.
If it so happens that your database file is big (more than 1MB) combine with this answer in order to achieve the shipment.

- 1
- 1

- 46,145
- 15
- 108
- 135