Is READ_WRITE_PERMISSION still necessary?

The wiki and the API sample app say my app needs to dynamically request READ_WRITE_PERMISSION to write to the AnkiDroid database. However, in my tests everything seems to work fine without requesting the permission. This is true whether AnkiDroid is installed on the user’s phone before my app or after.

After a bit of digging, I found that this is likely due to the AnkiDroid’s change to using ContentProvider in version 2.16. This was over two years ago, but the wiki and sample still mention the permission thing as a requirement. So I wanted to ask here to confirm: is it that those resources are out of date, or is it that it IS actually still required and my tests are missing something?

It’s been a while since i worked with the CardContentProvider, but at the time I did have to set/request the permission in the calling app to use it. And looking at the source, it does seem to check for it:

NB: this is only if you’re interacting with the db via the content provider

1 Like

Interesting. Thanks for the lead. Reading through the call sites of that function, it looks like if I have the READ_WRITE_PERMISSIONS line in my manifest (which I do) then I don’t need the dynamic permission for queries or inserts, but do need it only for updates and deletes?

Update: It looks like they just stealth changed this behavior with the 2.21.0 release a few days ago. And it wasn’t mentioned in the changelog. :cry:

It now unconditionally enforces it for queries too, not just updates and deletes. I don’t know why. Was it because of this thread? I found the commit but it doesn’t say anything. It would be nice if the commit messages had a bit more detail about the reasons for changes, or at least link to the issue tracker.