j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 366 forks source link

Android 8. Database and device protected storage #104

Open nikedlab opened 5 years ago

nikedlab commented 5 years ago

It is unable to use database when device just booted and not unlocked yet. I got error

SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database

I know it is issue of Credential Encrypted Storage, and when I try to get OrmLiteSqliteOpenHelper with DeviceProtectedStorageContext I still got same error

There is my code, may be I doing something wrong?

Context safeContext = ContextCompat.createDeviceProtectedStorageContext(appContext);
if (safeContext == null) {
    safeContext = appContext;
}
databaseHelper = OpenHelperManager.getHelper(safeContext, DatabaseHelper.class);

Thank you