I'm updating the target sdk version on an android app and in the process, I picked up the sqlite db importer is broken. Previously on android version >= 29, the importer worked fine.
So Basically, the android app has its own internal sqlite, During the import process, it opens an external db and imports the data into its internal database. The app uses the code below to open the db from sqliteHelper in Section A. To select and set the db name and path, the app uses the android file-selector "startActivityForResult" with an intent. Any ideas or suggestions will be appreciated. I'm setting this permission in manifest and during runtime: android.permission.WRITE_EXTERNAL_STORAGE
Section A
SQLiteDatabase db = ImportDBHelper.getInstance(context).getReadableDatabase();
public class ImportDBHelper extends SQLiteOpenHelper {
public static String DATABASE_NAME = "None";
public static final int DATABASE_VERSION = 10;
private static ImportDBHelper instance;
private ImportDBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public static synchronized ImportDBHelper getInstance(Context context) {
if (instance == null) {
instance = new ImportDBHelper(context);
}
return instance;
}
}```
2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (14) cannot open file at line 40888 of [bcd014c473] 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (14) os_unix.c:40888: (13) open(/storage/emulated/0/Download/B3.sqlite) - 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Process m.genioroasters : Pid (17932) Uid (10286) Euid (10286) Gid (10286) Egid (10286) 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Stat of /storage/emulated/0/Download/B3.sqlite : st_mode (100660) st_uid (0) st_gid (9997) st_ino(15987) st_size(110592) 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Stat of /storage/emulated/0/Download : st_mode(40770) st_uid(0) st_gid(9997) st_ino(6634) 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Stat of /storage/emulated/0 : st_mode(40770) st_uid(0) st_gid(9997) st_ino(4856) 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Stat of /storage/emulated : st_mode(40711) st_uid(0) st_gid(9997) st_ino(238) 2022-07-02 16:04:27.483 17932-18316/app.example E/SQLiteLog: (1) Stat of /storage : st_mode(40711) st_uid(2000) st_gid(9997) st_ino(13855)
2022-07-02 16:04:27.490 17932-18316/app.example E/SQLiteDatabase: Failed to open database '/storage/emulated/0/Download/B3.sqlite'. android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/Download/B3.sqlite': File /storage/emulated/0/Download/B3.sqlite is not readable at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:371) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:736) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1415) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1356) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:997) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:480) at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:437) at app.example.adapters.DatabaseAdapter.importDatabase(DatabaseAdapter.java:578) at app.example.Views.ParentActivity$1DBimporter.doInBackground(ParentActivity.java:260) at app.example.Views.ParentActivity$1DBimporter.doInBackground(ParentActivity.java:247) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:920) Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2318 SQLITE_CANTOPEN_EACCES[2318]): Could not open database