0

I write the code of database copy in /data/data path. but it gives this error

sqlite3_open_v2("/data/data/com.mycom.package/databases/My Bookback", &handle, 2, NULL) failed 

Caused by: android.database.sqlite.SQLiteException: unable to open  database file and copy.  05-23 13:19:46.746: ERROR/AndroidRuntime(9120): 
Caused by: android.database.sqlite.SQLiteException: no such table: Details: ,
Mike Woodhouse
  • 51,832
  • 12
  • 88
  • 127
moon
  • 13
  • 6

2 Answers2

1

The problem is that the dest directory could not be present on filesystem.

I resolved in this way.

File fDir = new File(DB_PATH);
if (!fDir.exists()) {
    Log.d(TAG, "Create directory " + fDir.getAbsolutePath() + " - " + fDir.mkdir());
}
Rolando
  • 11
  • 1
-1

Copying the database from assets is generally a bad idea. DB should be created/accessed through the SQLiteOpenHelper class. You can use the onCreate method to populate the DB content.

Kalarani
  • 407
  • 4
  • 11