Skip to content Skip to sidebar Skip to footer

Open Database For Readwirte Not Possible On Specific Device

I simply try to open a database in READWRITE Mode. I get the following error: 'not an error (code 0): Could not open the database in read/write mode.' When opening the DB the same

Solution 1:

Looks like that this is not bug, but "feature".

Google's KitKat Blocks Some Access to Micro SD Cards

It's really sad, but looks like true

Solution 2:

I'll preface this by saying you should really be storing SQLite databases on internal storage, where you have the benefit of ext4 journaling to help with data recovery. There is also much better security on internal storage, since you don't have to worry about malicious apps adding triggers, etc that end up running in your process.

That all being said, starting in KitKat you can write to secondary storage devices through the new public APIs Context.getExternalFilesDirs() or Context.getExternalCacheDirs(). These methods are also available on ContextCompat in the support-v4 library.

Also note that if you're only interested in using the directories returned by Context, you no longer need the READ_ or WRITE_EXTERNAL_STORAGE permissions. Going forward, you'll always have read/write access to these directories with no additional permissions required.

Apps can also continue working on older devices by end-of-lifing their permission request like this:

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"android:maxSdkVersion="18" />

Post a Comment for "Open Database For Readwirte Not Possible On Specific Device"