ContentResolver notifyChange - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContentResolver notifyChange method.

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);
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
 
        int result = -1;
 
        switch (uriType) {
            case DB_PERSON_ID:
                id = uri.getPathSegments().get(1);
                result = db.delete(uriType.getTableName(), whereWithId(id, selection), 
                        selectionArgs);
                break; 
            case DB_PERSON:
                result = db.delete(uriType.getTableName(), selection, selectionArgs);
                break; 
        } 
 
        getContext().getContentResolver().notifyChange(uri, null);
        return result;
    } 
 
    @Override 
    public String getType(Uri uri) {
7
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        SQLiteDatabase db = mHelper.getWritableDatabase();
        int count = 0;
        switch (mUriMatcher.match(uri)) {
            case CODE_SINGLE:
                String rowId = uri.getPathSegments().get(1);
                if (TextUtils.isEmpty(selection)) {
                    count = db.delete(mTableName, BaseColumns._ID + "=?", new String[] { rowId });
                } else { 
                    count = db.delete(mTableName,
                        selection + " AND " + BaseColumns._ID + "=" + rowId,
                        selectionArgs);
                } 
                break; 
            case CODE_COLLECTION:
                count = db.delete(mTableName, selection, selectionArgs);
                break; 
        } 
        getContext().getContentResolver().notifyChange(uri, null);
        return count;

7
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
    } 
 
    @Override 
    public synchronized int update(Uri uri, ContentValues values, String selection,
            String[] selectionArgs) {
        assert(uri.getPathSegments().size() == 1);
 
        // In this sample, we only update the content provider individually for each row with new 
        // temperature values. 
        final int index = Integer.parseInt(uri.getPathSegments().get(0));
        final MatrixCursor c = new MatrixCursor(
                new String[]{ Columns.ID, Columns.DAY, Columns.TEMPERATURE });
        assert(0 <= index && index < sData.size());
        final WeatherDataPoint data = sData.get(index);
        data.degrees = values.getAsInteger(Columns.TEMPERATURE);
 
        // Notify any listeners that the data backing the content provider has changed, and return 
        // the number of rows affected. 
        getContext().getContentResolver().notifyChange(uri, null);
        return 1; 

6
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
        case SETTINGS:
            count = db.delete(TABLE_NAME, selection, selectionArgs);
            break; 
 
        case SETTINGS_ID:
            String segment = uri.getPathSegments().get(1);
 
            if (TextUtils.isEmpty(selection)) {
                selection = "_id=" + segment;
            } else { 
                selection = "_id=" + segment + " AND (" + selection + ")";
            } 
 
            count = db.delete(TABLE_NAME, selection, selectionArgs);
            break; 
 
        default: 
            throw new IllegalArgumentException("Cannot delete from URI: " + uri);
        } 
 

7
CodeRank
This code example shows how to use the following methods:notifyChange, getLastPathSegment
			String[] whereArgs) {
		switch (_uriMatcher.match(uri)) {
		case SUBSCRIPTIONS:
			break; 
		case SUBSCRIPTION_ID:
			String extraWhere = COLUMN_ID + " = " + uri.getLastPathSegment();
			if (where != null)
				where = extraWhere + " AND " + where;
			else 
				where = extraWhere;
			break; 
		default: 
			throw new IllegalArgumentException("Unknown URI");
		} 
 
		SQLiteDatabase db = _dbAdapter.getWritableDatabase();
		int count = db.update("subscriptions", values, where, whereArgs);
		if (!URI.equals(uri))
			getContext().getContentResolver().notifyChange(uri, null);
		getContext().getContentResolver().notifyChange(URI, null);

6
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
 
        if (sMatcher.match(uri) == TEMPLATES) {
            count = mDb.delete(TABLE_NAME, selection, selectionArgs);
        } 
        else { 
            String segment = uri.getPathSegments().get(1);
            count = mDb
                    .delete(TABLE_NAME, Template._ID + "="
                            + segment
                            + (!TextUtils.isEmpty(selection) ? " AND (" + selection
                                    + ')' : ""), selectionArgs);
        } 
 
        getContext().getContentResolver().notifyChange(uri, null);
        return count;
    } 
 
    @Override 
    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
        int count;
7
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
		case HOSTS:
			count = db.delete(HOSTS_TABLE_NAME, where, whereArgs);
			break; 
 
		case HOST_ID:
			String hostId = uri.getPathSegments().get(1);
			count = db.delete(HOSTS_TABLE_NAME, Hosts._ID + "=" + hostId + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
			break; 
 
		default: 
			throw new IllegalArgumentException("Unknown URI " + uri);
		} 
 
		getContext().getContentResolver().notifyChange(uri, null);
		return count;
	} 
 
	@Override 
	public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
		SQLiteDatabase db = mOpenHelper.getWritableDatabase();
7
CodeRank
This code example shows how to use the following methods:notifyChange, getLastPathSegment
			dbHelper.getWritableDatabase().delete(Schema.TBL_WAYPOINT, Schema.COL_TRACK_ID + " = ?", new String[] {trackId});
			dbHelper.getWritableDatabase().delete(Schema.TBL_TRACKPOINT, Schema.COL_TRACK_ID + " = ?", new String[] {trackId});
			count = dbHelper.getWritableDatabase().delete(Schema.TBL_TRACK, Schema.COL_ID + " = ?", new String[] {trackId});
			break; 
		case Schema.URI_CODE_WAYPOINT_UUID:
			String uuid = uri.getLastPathSegment();
			if(uuid != null){
				count = dbHelper.getWritableDatabase().delete(Schema.TBL_WAYPOINT, Schema.COL_UUID + " = ?", new String[]{uuid});
			}else{ 
				count = 0;
			} 
			break; 
		default: 
			throw new IllegalArgumentException("Unknown URI: " + uri);
		} 
 
		getContext().getContentResolver().notifyChange(uri, null);
		return count;
	} 
 

6
CodeRank
This code example shows how to use the following methods:notifyChange, getPathSegments
                // Starts creating the final WHERE clause by restricting it to 
                // the incoming ID. 
                finalSelection =
                        Journeys._ID +
                        " = " + 
                        uri.getPathSegments().
                            get(Journeys.JOURNEY_ID_PATH_POSITION)
                ; 
 
                // If there were additional selection criteria, append them to 
                // the final WHERE clause. 
                if (selection !=null) {
                    finalSelection = finalSelection + " AND " + selection;
                } 
 
                count = db.update(
                    JOURNEYS_TABLE_NAME,
                    values,
                    finalSelection,
                    selectionArgs

6
CodeRank

Related ContentResolver notifyChange Questions & Answers:

notifyChange Method Overview
Notify registered observers that a row was updated.
See Code Examples for other Android ContentResolver Methods: