예제 #1
0
 private void updateOne() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   Uri newUri = ContentUris.withAppendedId(uri, 2); // 后面的数字指数据库中第几行
   ContentValues values = new ContentValues();
   values.put(MusicDB.MusicInfoColumns.MUSICNAME, "20xx");
   getContentResolver().update(newUri, values, null, null);
 }
예제 #2
0
 private void update() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   //		Uri newUri = ContentUris.withAppendedId(uri,MusicDBProvider.MUSICINFO_ITEM);
   ContentValues values = new ContentValues();
   values.put(MusicDB.MusicInfoColumns.MUSICNAME, "20xx");
   String where = MusicDB.MusicInfoColumns.MUSICNAME + " = ?";
   LogUtil.d("where= " + where);
   String[] selectionArgs = {"name_3"};
   getContentResolver().update(uri, values, where, selectionArgs);
 }
예제 #3
0
 private void insertDB() {
   LogUtil.d("insertDB");
   for (int i = 0; i < 5; i++) {
     Uri uri = MusicDB.MusicInfoColumns.getContentUri();
     LogUtil.d("uri= " + uri);
     ContentValues values = new ContentValues();
     values.put(MusicDB.MusicInfoColumns.MUSICNAME, "name_" + i);
     this.getContentResolver().insert(uri, values);
   }
 }
예제 #4
0
 private void queryOne() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   String[] projection = {MusicDB.MusicInfoColumns.MUSICNAME};
   String where = MusicDB.MusicInfoColumns.MUSICNAME + " = ?";
   String[] selectionArgs = {"name_1"};
   Cursor c = getContentResolver().query(uri, projection, where, selectionArgs, null);
   while (c.moveToNext()) {
     String name = c.getString(c.getColumnIndex(MusicDB.MusicInfoColumns.MUSICNAME));
     LogUtil.d("name= " + name);
   }
 }
예제 #5
0
  private void query() {
    Uri uri = MusicDB.MusicInfoColumns.getContentUri();
    String[] projection = {MusicDB.MusicInfoColumns.MUSICNAME};

    Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
    String name = "";
    cursor.moveToFirst();
    for (int i = 0; i < cursor.getCount(); i++) {
      cursor.moveToPosition(i);
      name = cursor.getString(cursor.getColumnIndex(MusicDB.MusicInfoColumns.MUSICNAME));
      LogUtil.d("name= " + name);
      //			cursor.moveToNext();
    }
  }
예제 #6
0
 private void deleteOne() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   String selection = MusicDB.MusicInfoColumns.MUSICNAME + " = ?";
   String[] selectionArgs = {"name_2"};
   getContentResolver().delete(uri, selection, selectionArgs);
 }
예제 #7
0
 private void delete() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   getContentResolver().delete(uri, null, null);
 }