I'm trying to deploy an application with an existing SQLite database.
I've read through and attempted to implement several samples online however I've found that they are always missing some code and either do not compile or work as advertised.
Does anyone have a Full Android Database Helper class for deploying an existing SQLite database on Android?
This is what I came up with, hope it helps others that were having troubles.
Make sure you create DatabaseHelper object once during application lifetime and reuse it.
For reading data:
For reading/modification data:
next use
insert()
,query()
,update()
,delete()
methods of SQLiteDatabase object:http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
You also should not create the database by directly accesssing the sqlite file what you do in createNewDatabase method. Use execSQL() method of SQLiteDatabase object in your onCreate(...) method. Execute your CREATE TABLE queries there.