Android ContentProvider - 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 ContentProvider class.

This code example shows how to use the following methods:getIContentProvider
         * Gets the content provider from the local map 
         */ 
        final ContentProvider provider = mProviders.get(name);
 
        if (provider != null) {
            return provider.getIContentProvider();
        } else { 
            return null; 
        } 
    } 
 
    /** @hide */ 
    @Override 
    public boolean releaseProvider(IContentProvider provider) {
        return true; 
    } 
 
    @Override 
    public void notifyChange(Uri uri, ContentObserver observer,
            boolean syncToNetwork) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:delete, insert, query
ContentProvider provider = getProvider();
    	 
    	Uri uri = EventStreamContentProvider.content_uri;
    	 
    	Uri entryUri = provider.insert(uri, null);
 
    	Cursor c = provider.query(uri, null, null, null, null);    	
    	int entries = c.getCount();
    	c.close();
    	 
    	int result = provider.delete(entryUri, null, null);
    	 
    	c = provider.query(uri, null, null, null, null);    	
    	int entriesnow = c.getCount();
    	c.close();
    	 
    	assertEquals(1, result);
    	assertTrue(entriesnow < entries);    
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getIContentProvider
         * Gets the content provider from the local map 
         */ 
        final ContentProvider provider = mProviders.get(name);
 
        if (provider != null) {
            return provider.getIContentProvider();
        } else { 
            return null; 
        } 
    } 
 
    /** @hide */ 
    @Override 
    public boolean releaseProvider(IContentProvider provider) {
        return true; 
    } 
 
    /** @hide */ 
    protected IContentProvider acquireUnstableProvider(Context c, String name) {
        return acquireProvider(c, name);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:shutdown
     * Calls {@link android.content.ContentProvider#shutdown()} on the 
     * {@link android.content.ContentProvider} represented by mProvider. 
     */ 
    @Override 
    protected void tearDown() throws Exception { 
        mProvider.shutdown();
        super.tearDown(); 
    } 
 
    /** 
     * Gets the {@link MockContentResolver2} created by this class during initialization. You 
     * must use the methods of this resolver to access the provider under test. 
     * 
     * @return A {@link MockContentResolver2} instance. 
     */ 
    public MockContentResolver2 getMockContentResolver() { 
        return mResolver;
    } 
 
    /** 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:insert
                childId = ContentUris.parseId(newItem);
 
                // no existing child or relation 
            } else { 
                if (mToContentUri != null) {
                    newItem = provider.insert(mToContentUri, values);
                    childId = ContentUris.parseId(newItem);
                } else { 
                    if (mTo != null) {
                        newItem = mTo.insertDir(db, provider, parentChildDir, values);
                        childId = ContentUris.parseId(newItem);
                    } else { 
                        childId = db.insert(mToTable, null, values);
                        if (childId != -1) {
                            newItem = ContentUris.withAppendedId(parentChildDir, childId);
                        } 
                    } 
                } 
            } 
 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:attachInfo
 
        ChromiumTestShellActivity activity = launchChromiumTestShellWithUrl(null);
        assertNotNull(activity);
 
        ContentProvider provider = new ChromeBrowserProvider();
        provider.attachInfo(activity, null);
 
        MockContentResolver resolver = new MockContentResolver();
        resolver.addProvider(ChromeBrowserProvider.getApiAuthority(activity), provider);
        resolver.addProvider(ChromeBrowserProvider.getInternalAuthority(activity), provider);
 
        mContext = new IsolatedContext(resolver, activity);
        assertTrue(getContentResolver() instanceof MockContentResolver);
    } 
 
    protected ContentResolver getContentResolver() {
        return mContext.getContentResolver();
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getItemCount, getIcon
 
    private void stash(ClipData clipping) {
        mClipping = clipping;
        if (mClipping != null) {
            setVisibility(View.VISIBLE);
            Bitmap icon = mClipping.getIcon();
//            mDescription.setText(mClipping.getDescription().getLabel()); 
            if (icon != null) {
                setImageBitmap(icon);
            } else { 
                if (mClipping.getItemCount() > 0) {
                    // TODO: figure out how to visualize every kind of ClipData! 
                    //mAltText.setText(mClipping.getItemAt(0).coerceToText(getContext())); 
                } 
            } 
        } else { 
            setVisibility(View.GONE);
        } 
    } 
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getItemAt
     
    if (clip==null) {
      Toast.makeText(this, "There is no clip!", Toast.LENGTH_LONG).show();
    } 
    else { 
      ClipData.Item item=clip.getItemAt(0);
      Uri song=item.getUri();
       
      if (song!=null &&
          getContentResolver().getType(song).startsWith("audio/")) {
        startActivity(new Intent(Intent.ACTION_VIEW, song));
      } 
      else { 
        Toast.makeText(this, "There is no song!", Toast.LENGTH_LONG).show();
      } 
    } 
  } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
                            target.getType()
                    }; 
                } else { 
                    mimeTypes = new String[]{};
                } 
                targetClipData = new ClipData(null, mimeTypes, item);
            } 
            if (targetClipData != null) {
                intent.setClipData(targetClipData);
                intent.addFlags(permFlags);
            } 
        } 
        return intent;
    } 
 
    private IntentCompat() { 
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getItemCount, getIcon
    } 
 
    private void stash(ClipData clipping) {
        mClipping = clipping;
        if (mClipping != null) {
            setVisibility(View.VISIBLE);
            Bitmap icon = mClipping.getIcon();
//            mDescription.setText(mClipping.getDescription().getLabel()); 
            if (icon != null) {
                setImageBitmap(icon);
            } else { 
                if (mClipping.getItemCount() > 0) {
                    // TODO: figure out how to visualize every kind of ClipData! 
                    //mAltText.setText(mClipping.getItemAt(0).coerceToText(getContext())); 
                } 
            } 
        } else { 
            setVisibility(View.GONE);
        } 
    } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android ContentProvider Questions & Answers:

See Code Examples for Android ContentProvider Methods: