I’m following Using your own SQLite database in your Android applications, and in the tutorial the author mentioned that I need to copy the sqlite file into “default system path”:
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/YOUR_PACKAGE/databases/";
and the method is:
/**
* Copies your database from your local assets-folder to the just created empty database in the
* system folder, from where it can be accessed and handled.
* This is done by transfering bytestream.
* */
private void copyDataBase() throws IOException{
Also I read the thread:
Do all Android devices have an internal SD card
The accepted answer stated:
Any device that has the Android Market will have at least 2GB of storage at Environment.getExternalStorageDirectory(). Whether that is an SD card or something else will vary by device.
So I’m wondering:
- Is the “default system path” the same as Environment.getExternalStorageDirectory()
- Do I need to substitude “/data/data/YOUR_PACKAGE/databases” with Environment.getExternalStorageDirectory() + “/YOUR_PACKAGE/databases”?
I did a test to print out the result of Environment.getExternalStorageDirectory() on Motorola Milestone(the one with physical QWERTY keyboard) and it returns:
Dir: /sdcard
So they are not the same, but which one should I use for SQLite database?
Thanks!
As already said databae is creates at
/data/data/YOUR_PACKAGE/databases/Look herethe
getDatabasePath()method returns the default database path, which is very convenient.