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

This code example shows how to use the following methods: query
  } 
 
  public static Bitmap getLocalUserContactPhoto(Context context, Uri uri) {
    if (uri == null) return getDefaultContactPhoto(context);
 
    Bitmap contactPhoto = localUserContactPhotoCache.get(uri);
 
    if (contactPhoto == null) {
      Cursor cursor = context.getContentResolver().query(uri, CONTENT_URI_PROJECTION,
                                                         null, null, null); 
 
      if (cursor != null && cursor.moveToFirst()) {
        contactPhoto = getContactPhoto(context, Uri.withAppendedPath(Contacts.CONTENT_URI,
                                       cursor.getLong(0) + ""));
      } else { 
        contactPhoto = getDefaultContactPhoto(context);
      } 
 
      localUserContactPhotoCache.put(uri, contactPhoto);
    } 

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: insert, openAssetFileDescriptor, query, update
	public void updatePhoto(ContentResolver cr, byte[] photo, String id, boolean markDirty, boolean fromthumb) { 
		if (cr == null || id == null) {
			return; 
		} 
		 
		long rawId = queryForRawContactId(cr, Long.parseLong(id));
		if (rawId < 0) {
			return; 
		} 
		//if(!fromthumb) 
			writeDisplayPhoto(cr, rawId, photo);
		 
		if(photo == null)
		{ 
			id = String.valueOf(rawId);
			ContentValues values = new ContentValues(); 
			int photoRow = -1; 
			 
			// query for existing photo 
			String where = ContactsContract.Data.RAW_CONTACT_ID + " == " + 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: update, put
    @Override 
    protected void onHandleIntent(Intent intent) {
        String action = intent.getAction();
        if (ACTION_CLEAR_MISSED_CALLS.equals(action)) {
            // Clear the list of new missed calls. 
            ContentValues values = new ContentValues();
            values.put(Calls.NEW, 0);
            values.put(Calls.IS_READ, 1);
            StringBuilder where = new StringBuilder();
            where.append(Calls.NEW);
            where.append(" = 1 AND ");
            where.append(Calls.TYPE);
            where.append(" = ?");
            getContentResolver().update(Calls.CONTENT_URI, values, where.toString(),
                    new String[]{ Integer.toString(Calls.MISSED_TYPE) });
            mApp.notificationMgr.cancelMissedCallNotification();
        } else if (ACTION_CLEAR_BLACKLISTED_CALLS.equals(action)) {
            mApp.notificationMgr.cancelBlacklistedCallNotification();
        } 
    } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: query
		 
	} 
 
	private void setupSocialFeed() { 
		socialFeedUri = FeedProvider.SOCIAL_FEEDS_URI.buildUpon().appendPath(userId).build();
		socialFeed = SocialFeed.fromCursor(contentResolver.query(socialFeedUri, null, null, null, null));
	} 
	 
	public static SocialFeedItemListFragment newInstance(final String userId, final String username, final int currentState) {
		return new SocialFeedItemListFragment(userId, username, currentState);
	} 
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.fragment_itemlist, null);
		itemList = (ListView) v.findViewById(R.id.itemlistfragment_list);
		itemList.setEmptyView(v.findViewById(R.id.empty_view));
		 
		itemList.setOnScrollListener(this);
		itemList.setAdapter(adapter);
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: notifyChange, getPathSegments
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        isValidUri(uri);
 
        SQLiteDatabase db = mBookOpenHelper.getWritableDatabase();
        // URIからテーブル名を取得 
        String tableName = uri.getPathSegments().get(0);
        int updatedCount = db.update(tableName, values, selection, selectionArgs);
        getContext().getContentResolver().notifyChange(uri, null);
        return updatedCount;
    } 
 
    // このContentProviderで使用可能なURIかを判定します。 
    // 使用不可の場合はIllegalArgumentExceptionを投げます。 
    private void isValidUri(Uri uri) {
        if (URI_MATCHER.match(uri) != Book.BOOK) {
            throw new IllegalArgumentException("Unknown URI : " + uri);
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android ContentResolver Questions & Answers:

Other Android ContentResolver Examples

68:	    values.put(MediaStore.Audio.Media.MIME_TYPE, "audio/3gpp");
69:	    values.put(MediaStore.Audio.Media.DATA, audiofile.getAbsolutePath());
70:	    ContentResolver contentResolver = getContentResolver();
71:	
72:	    Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

Read More

See Code Examples for Android ContentResolver Methods: