I am updating an application that works on API 29/Android Q devices but not Android 11. I understand that there are new scoped storage updates and am already receiving permissions from the user for
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
My code looks something like this:
//the path returns /data/user/0/com.company.MyApp/files/MyAppDB.sqlite
var Path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var asyncConn = new SQLiteAsyncConnection(Path);
try
{
await asyncConn.CreateTableAsync<SampleObject>();
return true;
}
catch (Exception ex)
{
return false;
}
When executing CreateTableAsync I receive an object reference error. This is only happening with Android 11 emulators/devices.
This does not seem to be an issue with SQLite but an issue accessing the sqlite file, or writing to it at least.