Access to database not possible in Android 11(+?)
Opened this issue · 1 comments
When using AWARE on Android 11 (or probably higher), the app crashes with an SQLiteDatabase Error, failing to open the database. The same app still works on older devices.
Probable cause: File system access has been restricted in Android 11 (see e. g. here). This will probably require the db to be in a different location, or getting access to all file using a special permission, which is not recommended, if it can be avoided.
Also, Environment.getExternalStoragePublicDirectory() which is used to get the database file has been deprecated now, so this should be replaced either way.
Is there any hope these issues will get fixed or should I try building a (possibly dirty) workaround, changing the source myself (which could be hard) or stop using the plugin (which would be sad)?
Heres the log of my app:
D/AWARE: created: com.aware.plugin.ambient_noise.Plugin package: app.me.phonestudy
E/SQLiteLog: (14) cannot open file at line 38589 of [b2325a6e1c]
E/SQLiteLog: (14) os_unix.c:38589: (2) open(/storage/emulated/0/AWARE/aware.db) -
E/SQLiteDatabase: Failed to open database '/storage/emulated/0/AWARE/aware.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/AWARE/aware.db': Directory /storage/emulated/0/AWARE doesn't exist
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:252)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:789)
at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:806)
at com.aware.utils.DatabaseHelper.getDatabaseFile(DatabaseHelper.java:244)
at com.aware.utils.DatabaseHelper.getWritableDatabase(DatabaseHelper.java:177)
at com.aware.providers.Aware_Provider.initialiseDatabase(Aware_Provider.java:232)
at com.aware.providers.Aware_Provider.query(Aware_Provider.java:471)
at android.content.ContentProvider.query(ContentProvider.java:1379)
at android.content.ContentProvider.query(ContentProvider.java:1475)
at android.content.ContentProvider$Transport.query(ContentProvider.java:278)
at android.content.ContentResolver.query(ContentResolver.java:1183)
at android.content.ContentResolver.query(ContentResolver.java:1115)
at android.content.ContentResolver.query(ContentResolver.java:1071)
at com.aware.Aware.getSetting(Aware.java:1076)
at com.aware.utils.Aware_Plugin.onStartCommand(Aware_Plugin.java:112)
at com.aware.plugin.ambient_noise.Plugin.onStartCommand(Plugin.java:33)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4326)
at android.app.ActivityThread.access$1800(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1951)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14 SQLITE_CANTOPEN): Could not open database
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:224)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:918)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:789)
at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:806)
at com.aware.utils.DatabaseHelper.getDatabaseFile(DatabaseHelper.java:244)
at com.aware.utils.DatabaseHelper.getWritableDatabase(DatabaseHelper.java:177)
at com.aware.providers.Aware_Provider.initialiseDatabase(Aware_Provider.java:232)
at com.aware.providers.Aware_Provider.query(Aware_Provider.java:471)
at android.content.ContentProvider.query(ContentProvider.java:1379)
at android.content.ContentProvider.query(ContentProvider.java:1475)
at android.content.ContentProvider$Transport.query(ContentProvider.java:278)
at android.content.ContentResolver.query(ContentResolver.java:1183)
at android.content.ContentResolver.query(ContentResolver.java:1115)
at android.content.ContentResolver.query(ContentResolver.java:1071)
at com.aware.Aware.getSetting(Aware.java:1076)
at com.aware.utils.Aware_Plugin.onStartCommand(Aware_Plugin.java:112)
at com.aware.plugin.ambient_noise.Plugin.onStartCommand(Plugin.java:33)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4326)
at android.app.ActivityThread.access$1800(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1951)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Is there any update on this issue ? Did you find a work around ?