public class UnstableContentResolverClient extends Object
Using this class to communicate with providers in other processes ensures that if the provider process dies your process will not die with it. This class also automatically retries for several seconds any operations that fail due to the provider process not being available, such as when the provider process has crashed or is being reinstalled.
Unlike the standard ContentProviderClient this class does not require you to release/close instances you obtain, instead this class acquires and releases the internal ContentProviderClient for each method invocation.
Note that methods in this class eat all usage exceptions and return null (or the default value as with the call method) instead.
Constructor and Description |
---|
UnstableContentResolverClient(ContentResolver contentResolver,
Uri uri) |
Modifier and Type | Method and Description |
---|---|
Bundle |
call(String method,
String arg,
Bundle extras,
Bundle defaultResult)
Perform
ContentProvider.call(String, String, String, Bundle) while
allowing for a provider that may not be available momentarily. |
int |
delete(String selection,
String[] selectionArgs)
Perform
ContentProvider.delete(Uri, String, String[]) while
allowing for a provider that may not be available momentarily. |
Uri |
insert(ContentValues values)
Perform
ContentProvider.insert(Uri, ContentValues) while
allowing for a provider that may not be available momentarily. |
AssetFileDescriptor |
openAssetFile(String mode)
Perform
ContentResolver.openAssetFileDescriptor(Uri, String) while
allowing for a provider that may not be available momentarily. |
Cursor |
query(String[] projection,
String selection,
String[] selectionArgs,
String sortOrder)
Perform
ContentProvider.query(Uri, String[], String, String[], String)
while allowing for a provider that may not be available momentarily. |
int |
update(ContentValues values,
String selection,
String[] selectionArgs)
Perform
ContentProvider.update(Uri, ContentValues, String, String[])
while allowing for a provider that may not be available momentarily. |
public UnstableContentResolverClient(ContentResolver contentResolver, Uri uri)
public Uri insert(ContentValues values)
ContentProvider.insert(Uri, ContentValues)
while
allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
public int update(ContentValues values, String selection, String[] selectionArgs)
ContentProvider.update(Uri, ContentValues, String, String[])
while allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
public int delete(String selection, String[] selectionArgs)
ContentProvider.delete(Uri, String, String[])
while
allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
public Cursor query(String[] projection, String selection, String[] selectionArgs, String sortOrder)
ContentProvider.query(Uri, String[], String, String[], String)
while allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
The caller must close the cursor when it is no longer needed.
public Bundle call(String method, String arg, Bundle extras, Bundle defaultResult)
ContentProvider.call(String, String, String, Bundle)
while
allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
public AssetFileDescriptor openAssetFile(String mode)
ContentResolver.openAssetFileDescriptor(Uri, String)
while
allowing for a provider that may not be available momentarily.
Note this implementation eats all exceptions, including ones resulting from improper usage
of the provider such as SecurityException, IllegalArgumentException, etc. See full list at
Parcel.writeException(Exception)
. Watch logs accordingly for errors.
ContentResolver.openAssetFileDescriptor(Uri, String)