Question

I have this code:

context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);

On some phones (user report it to me) it causes a:

java.lang.IllegalArgumentException: Unknown authority com.android.contacts

However similar authority is listed within installed packages:

contacts;com.android.contacts

or

com.google.contacts.gal.provider

Note contacts; prefix - does not seem good to me. I used this code to get it:

String message="";
for (android.content.pm.PackageInfo pack : context.getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)) {
 ProviderInfo[] providers = pack.providers;
 if (providers != null) {
  for (ProviderInfo provider : providers) {
  message=message+", "+provider.authority;
 }
 }
}

Do you think it's appropriate to failover to contacts;com.android.contact if com.android.contacts fails??

Was it helpful?

Solution

Contacts provider lists "contacts;com.android.contacts" in his authorities. This list should be parsed by a content resolver, you don't need to use this string as a authority.

Probably you need to find out more about phones with this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top