Android ContentProviderClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ContentProviderClient class.

This code example shows how to use the following methods:update
	} 
 
	@Override 
	public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
		try { 
			return mProvider.update(uri, values, selection, selectionArgs);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
		return 0; 
	} 
 
	/** 
	 * If you're reluctant to implement this manually, please just call 
	 * super.bulkInsert(). 
	 */ 
	@Override 
	public int bulkInsert(Uri uri, ContentValues[] values) {
		try { 
5
CodeRank
This code example shows how to use the following methods:getLocalContentProvider
				this.client = client;
			} 
 
			public ContentProvider getLocalContentProvider()
			{ 
				return client.getLocalContentProvider();
			} 
		} 
	} 
 
	private static class ThroughReflection extends AcquireProvider 
	{ 
		private final Class<?> icpClass;
 
		private static class Holder 
		{ 
			private static final ThroughReflection sInstance = new ThroughReflection();
		} 
 
		private ThroughReflection() 
5
CodeRank
This code example shows how to use the following methods:applyBatch
	protected abstract Uri entriesURI();
	public abstract void clearDirty(Resource resource);
	 
	public void commit() throws RemoteException, OperationApplicationException { 
		if (!pendingOperations.isEmpty())
			providerClient.applyBatch(pendingOperations);
		pendingOperations.clear();
	} 
} 
5
CodeRank
This code example shows how to use the following methods:query
This code example shows how to use the following methods:getType
	 * @throws RemoteException 
	 *             if there is an error communicating with the provider 
	 */ 
	public Class<? extends JsonSyncableItem> getSyncClass(ContentProviderClient provider, Uri data)
			throws SyncException, RemoteException { 
		final String type = provider.getType(data);
 
		final Class<? extends JsonSyncableItem> syncable = TYPE_MAP.get(type);
		if (syncable == null) {
			throw new SyncException("cannot find " + data + ", which has type " + type
					+ ", in the SyncEngine's sync map"); 
		} 
		return syncable;
	} 
 
	/** 
	 * Retrieves the sync map from the class that maps to the given uri 
	 * 
	 * @param provider 
	 * @param toSync 
3
CodeRank
This code example shows how to use the following methods:getLocalContentProvider, release
        @Override 
        protected Void doInBackground(CellBroadcastOperation... params) {
            ContentProviderClient cpc = mContentResolver.acquireContentProviderClient(
                    CellBroadcastContentProvider.CB_AUTHORITY);
            CellBroadcastContentProvider provider = (CellBroadcastContentProvider)
                    cpc.getLocalContentProvider();
 
            if (provider != null) {
                try { 
                    boolean changed = params[0].execute(provider);
                    if (changed) {
                        Log.d(TAG, "database changed: notifying observers...");
                        mContentResolver.notifyChange(CONTENT_URI, null, false);
                    } 
                } finally { 
                    cpc.release();
                } 
            } else { 
                Log.e(TAG, "getLocalContentProvider() returned null");
            } 
 
5
CodeRank
This code example shows how to use the following methods:delete
    //    public final Bundle call(String method, String arg, Bundle extras) throws RemoteException { 
    //        return mUnderlying.call(method, arg, extras); 
    //    } 
 
    public final int delete(Uri url, String selection, String[] selectionArgs) throws RemoteException {
        return mUnderlying.delete(url, selection, selectionArgs);
    } 
 
    public boolean equals(Object o) {
        return mUnderlying.equals(o);
    } 
 
    public final ContentProvider getLocalContentProvider() {
        return mUnderlying.getLocalContentProvider();
    } 
 
    public final String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
        return mUnderlying.getStreamTypes(url, mimeTypeFilter);
    } 
 
4
CodeRank
This code example shows how to use the following methods:release
   * After invoking this method, this instance should be discarded. 
   */ 
  public void releaseProviders() { 
    try { 
      if (providerClient != null) {
        providerClient.release();
      } 
    } catch (Exception e) {
    } 
    providerClient = null;
  } 
 
  @Override 
  protected void finalize() throws Throwable { 
    this.releaseProviders();
    super.finalize(); 
  } 
 
  private static String[] HISTORY_MIGRATION_COLUMNS = new String[] { Control.ENSURE_HISTORY_MIGRATED };
  private static String[] BOOKMARKS_MIGRATION_COLUMNS = new String[] { Control.ENSURE_BOOKMARKS_MIGRATED };

4
CodeRank
This code example shows how to use the following methods:applyBatch
		} 
 
		public void applyChanges() { 
			try { 
				Log.v(TAG, "Applying " + mBatch.size() + " operations to contacts DB...");
				mProvider.applyBatch(mBatch); 
				mBatch.clear(); 
			} catch (RemoteException e) {
				Log.e(TAG, "Could not sync contacts", e);
				mSyncResult.databaseError = true; 
			} catch (OperationApplicationException e) {
				Log.e(TAG, "Could not sync contact", e);
				mSyncResult.databaseError = true; 
			} 
		} 
	} 
	 
	public LDAPSyncAdapter(Context ctx)
	{ 
		super(ctx, true);
4
CodeRank
This code example shows how to use the following methods:release
   * After invoking this method, this instance should be discarded. 
   */ 
  public void releaseProviders() { 
    try { 
      if (providerClient != null) {
        providerClient.release();
      } 
    } catch (Exception e) {
    } 
    providerClient = null;
  } 
 
  @Override 
  protected void finalize() throws Throwable { 
    this.releaseProviders();
    super.finalize(); 
  } 
 
  private static String[] HISTORY_MIGRATION_COLUMNS = new String[] { Control.ENSURE_HISTORY_MIGRATED };
  private static String[] BOOKMARKS_MIGRATION_COLUMNS = new String[] { Control.ENSURE_BOOKMARKS_MIGRATED };

4
CodeRank

Related Android ContentProviderClient Questions & Answers:

See Code Examples for Android ContentProviderClient Methods: