@Override
public
Uri insert(Uri uri, ContentValues values) {
db = dbHelper.getWritableDatabase();
long
rowId = db.insert(TAGDBOpenHelper.TABLE_NAME_TAG,
""
, values);
if
(rowId >
0
) {
Uri newUrl = ContentUris.withAppendedId(TAGDBOpenHelper.CONTENT_URI, rowId);
getContext().getContentResolver().notifyChange(newUrl,
null
);
return
newUrl;
}
return
null
;
}
@Override
public
int
delete(Uri uri, String where, String[] whereArgs) {
db = dbHelper.getWritableDatabase();
int
count =
0
;
switch
(matcher.match(uri)) {
case
TAGDBOpenHelper.TAG:
count = db.delete(TAGDBOpenHelper.TABLE_NAME_TAG, where, whereArgs);
break
;
case
TAGDBOpenHelper.TAG_ID:
long
parseId = ContentUris.parseId(uri);
where =
" _id = "
+ parseId ;
count = db.delete(TAGDBOpenHelper.TABLE_NAME_TAG, where,
null
);
break
;
}
getContext().getContentResolver().notifyChange(uri,
null
);
return
count;
}
@Override
public
Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
db = dbHelper.getReadableDatabase();
int
match = matcher.match(uri);
Cursor cursor =
null
;
switch
(match) {
case
TAGDBOpenHelper.TAG:
cursor = db.query(TAGDBOpenHelper.TABLE_NAME_TAG,
null
,
null
,
null
,
null
,
null
,
null
);
cursor.setNotificationUri(getContext().getContentResolver(), uri);
break
;
}
return
cursor;
}