tags:

views:

227

answers:

1

Newbie Q coming from iPhone/MonoTouch C# background

I have an existing SQLite database file from another project.

Where do I include the database file into my Eclipse project to have it deploy with the app.

Do I need to indicate that the database file is writable? (In the iPhone world you need to copy the database file from the app's bundle to a writable folder on the iPhone proper before first use.)

Once I have the database file on the phone, how do I tell SQLiteOpenHelper to use it? (I extend SQLiteOpenHelper in a custom class.

+1  A: 

Where do I include the database file into my Eclipse project to have it deploy with the app.

You can place the db file in either res/raw or assets/.

Do I need to indicate that the database file is writable? (In the iPhone world you need to copy the database file from the app's bundle to a writable folder on the iPhone proper before first use.)

With Android, you'll have to copy the file from your bundle into the app's database directory. Then, your app should be able to open the database using SQLiteOpenHelper as you would any other database created by your app.

To open the file (assuming you placed it in res/raw), call Resource.openRawResource(id) and to get the destination directory, call Context.getDatabasePath(filename). The database path might not exist, so you might need to create the parent directories first.

Erich Douglass