Android Question Android 11 error writing contacts: java.lang.SecurityException


Active Member
Licensed User
Longtime User
I'm puzzled. When writing contacts (trying to make any kind of modifications to contacts data) I'm getting the below error; the code works fine on Android 7, but not on my new toy with Android 11 (Xiaomi Redmi Note 10), B4A 10.90:

java.lang.SecurityException: Permission Denial: writing uri content:// from pid=25498, uid=10316 requires android.permission.WRITE_CONTACTS, or grantUriPermission()
at android.os.Parcel.createExceptionOrNull(
at android.os.Parcel.createException(
at android.os.Parcel.readException(
at android.database.DatabaseUtils.readExceptionFromParcel(
at android.database.DatabaseUtils.readExceptionFromParcel(
at android.content.ContentProviderProxy.insert(
at android.content.ContentResolver.insert(
at android.content.ContentResolver.insert(
at anywheresoftware.b4a.objects.ContentResolverWrapper.Insert(
at b4a.contactserror.wmcontactsutils._insertcontact(
at b4a.contactserror.b4xmainpage._button1_click(
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(
at anywheresoftware.b4a.BA.raiseEvent(
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(
at android.view.View.performClick(
at android.view.View.performClickInternal(
at android.view.View.access$3600(
at android.view.View$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)

RuntimePermissions PERMISSION_READ_CONTACTS and PERMISSION_WRITE_CONTACTS have been requested and granted, and the Manifest contains AddPermission lines for both. The error occurs in wmContactUtils.InsertContact, at line 457:
Dim rawUri As Uri = cr.Insert(rawContactUri, values)
Any hints would be greatly appreciated as I'm clueless... The attached test project contains one external library: Clipboard, to copy the StackTrace to the clipboard. This library can be found at

Thanks in advance!


    26.4 KB · Views: 229