Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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();
    }
  }
Ejemplo n.º 6
0
 private void deleteOne() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   String selection = MusicDB.MusicInfoColumns.MUSICNAME + " = ?";
   String[] selectionArgs = {"name_2"};
   getContentResolver().delete(uri, selection, selectionArgs);
 }
Ejemplo n.º 7
0
 private void delete() {
   Uri uri = MusicDB.MusicInfoColumns.getContentUri();
   getContentResolver().delete(uri, null, null);
 }