本文整理匯總了Java中android.content.ContentProviderClient.query方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentProviderClient.query方法的具體用法?Java ContentProviderClient.query怎麽用?Java ContentProviderClient.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.ContentProviderClient
的用法示例。
在下文中一共展示了ContentProviderClient.query方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runInternal
import android.content.ContentProviderClient; //導入方法依賴的package包/類
public void runInternal() {
ContentProviderClient client = null;
try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(
getContext().getContentResolver(), authority);
final Uri uri = DocumentsContract.buildRecentDocumentsUri(authority, rootId);
final Cursor cursor = client.query(
uri, null, null, null, DirectoryLoader.getQuerySortOrder(mSortOrder));
mWithRoot = new RootCursorWrapper(authority, rootId, cursor, MAX_DOCS_FROM_ROOT);
} catch (Exception e) {
Log.w(TAG, "Failed to load " + authority + ", " + rootId, e);
} finally {
ContentProviderClientCompat.releaseQuietly(client);
}
set(mWithRoot);
mFirstPassLatch.countDown();
if (mFirstPassDone) {
onContentChanged();
}
}
示例2: updateFromUri
import android.content.ContentProviderClient; //導入方法依賴的package包/類
public void updateFromUri(ContentResolver resolver, Uri uri) throws FileNotFoundException {
ContentProviderClient client = null;
Cursor cursor = null;
try {
client = DocumentsApplication.acquireUnstableProviderOrThrow(
resolver, uri.getAuthority());
cursor = client.query(uri, null, null, null, null);
if (!cursor.moveToFirst()) {
throw new FileNotFoundException("Missing details for " + uri);
}
updateFromCursor(cursor, uri.getAuthority());
} catch (Throwable t) {
throw asFileNotFoundException(t);
} finally {
IoUtils.closeQuietly(cursor);
ContentProviderClientCompat.releaseQuietly(client);
}
}
示例3: query
import android.content.ContentProviderClient; //導入方法依賴的package包/類
/**
* 調用插件裏的Provider
*
* @see android.content.ContentProviderClient#query(Uri, String[], String, String[], String)
*/
public static Cursor query(Context c, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
ContentProviderClient client = PluginProviderClient.acquireContentProviderClient(c, "");
if (client != null) {
try {
Uri toUri = toCalledUri(c, uri);
return client.query(toUri, projection, selection, selectionArgs, sortOrder);
} catch (RemoteException e) {
if (LogDebug.LOG) {
Log.d(TAG, e.toString());
}
}
}
if (LogDebug.LOG) {
Log.d(TAG, String.format("call query1 %s fail", uri.toString()));
}
return null;
}
示例4: query
import android.content.ContentProviderClient; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder) {
String targetAuthority = uri.getQueryParameter(Env.EXTRA_TARGET_AUTHORITY);
if (!TextUtils.isEmpty(targetAuthority) && !TextUtils.equals(targetAuthority, uri.getAuthority())) {
ContentProviderClient client = getContentProviderClient(targetAuthority);
try {
return client.query(buildNewUri(uri, targetAuthority), projection, selection, selectionArgs, sortOrder);
} catch (RemoteException e) {
handleExpcetion(e);
}
}
return null;
}