I have 2 applications and 1 library project in the workspace. 1st app creates a database, test.db and exits which works fine (database is created properly). 2nd app tries to open the database and fails. Database access is done via the same library in both apps. When the 2nd app tries to open the database, it gets an exception:
E/SQLiteDatabase(26994): Failed to open database'/storage/emulated/0/Android/data/com.mydblib/databases/test.db'.
E/SQLiteDatabase(26994): android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
The code to open database:
File dbDir = new File(dbDirectory);
if (!dbDir.exists()) {
dbDir.mkdirs();
}
File dbFile = new File(dbDir, DATABASE_NAME);
// This causes exception in the 2nd app but works fine in the 1st one:
SQLiteDatabase.openOrCreateDatabase(dbFile, null);
What could be the reason for this error? Thanks.