views:

2150

answers:

2

I already found out that there is no way to bundle files in an .apk and have them on /sdcard, the best option so far being to download the large files upon first run. I came accross a tutorial saying how to bundle an sqlite db with the apk and then copy it so that it can be accessed with SQLiteDatabase (thus doubling the space needed, and not using /sdcard at all).

http://developer.android.com/guide/topics/data/data-storage.html#db says all databases MUST be in /data/data/package_name/databases.

Is that really so? Is there a way to trick the framework into opening a database that is placed on the /sdcard partition? Is there a way to use another SQLite java wrapper/framework to access such databases?

If the answer to the above is 'No', what other options do I have? My data is very well represented in a relational model, but is just too big, plus, I want to be able to update it without the need to reinstall/upgrade the entire app.

+12  A: 

Sure you can. The docs are a little conflicting about this as they also say that no limitations are imposed. I think they should say that relative paths are to the above location and dbs there ARE private. Here is the code you want:

File dbfile = new File("/sdcard/mydb.sqlite" ); 
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
System.out.println("Its open? "  + db.isOpen());
AdamC
A: 

Then can we access that database file from all activities in out application??? I was not able to do tht conventionally!!

Ashik