Android組件之自定義ContentProvider
Uri uri = Uri
本文引用地址:http://www.ex-cimer.com/article/201609/304417.htm.parse(content://com.example.googlecontentprovider.MyContentProvider/book/delete);
ContentResolver resolver = getContext().getContentResolver();
String where = id=?;
String[] argString = {10};
int count = resolver.delete(uri, where, argString);
Log.i(BookCase, 刪除了 + count + 行);
查詢所有的數(shù)據(jù):
public void bookQuery() {
Uri uri = Uri
.parse(content://com.example.googlecontentprovider.MyContentProvider/book/query);
ContentResolver resolver = getContext().getContentResolver();
Cursor cursor=resolver.query(uri, new String[]{id,Name,Title}, null, null, null);
if (cursor.getCount()>0) { String titleString=cursor.getString(cursor.getColumnIndex(Title));
Log.i(BookCase, id+---+nameString+---+titleString);
}
}
}
評論