'SQLiteCantOpenDatabaseException Cannot open database : is not readable
I am using Room DB to save data locally in android.
Now, I want to preserve the data even user uninstall the application or do clear storage.
So, I created Room DB in following location.
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getPath()
Everything works fine.
But if I clear the storage or uninstall the application and I open the application again, I am getting following error.
Caused by: java.util.concurrent.ExecutionException: android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/storage/emulated/0/Download/database/hhcf': File /storage/emulated/0/Download/database/hhcf is not readable
This issue coming in Android 11. For Android 9 no excetion is there.
I have granted following permissions as well.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
And,
android:requestLegacyExternalStorage="true"
in application tag.
Any help would be appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
