Exemplo n.º 1
0
 public Label tambahLabel(String judul, String warnaLatar) {
   Label res = new Label(-1, judul, getUrutanTerbesarLabel() + 1, warnaLatar);
   SQLiteDatabase db = helper.getWritableDatabase();
   long _id = db.insert(Db.TABEL_Label, null, res.toContentValues());
   if (_id == -1) {
     return null;
   } else {
     res._id = _id;
     return res;
   }
 }
Exemplo n.º 2
0
 /** @return null when not found */
 public List<Label> listLabels(long bukmak2_id) {
   List<Label> res = null;
   Cursor cursor =
       helper
           .getReadableDatabase()
           .rawQuery(
               "select "
                   + Db.TABEL_Label
                   + ".* from "
                   + Db.TABEL_Label
                   + ", "
                   + Db.TABEL_Bukmak2_Label
                   + " where "
                   + Db.TABEL_Bukmak2_Label
                   + "."
                   + Db.Bukmak2_Label.label_id
                   + " = "
                   + Db.TABEL_Label
                   + "."
                   + BaseColumns._ID
                   + " and "
                   + Db.TABEL_Bukmak2_Label
                   + "."
                   + Db.Bukmak2_Label.bukmak2_id
                   + " = ?  order by "
                   + Db.TABEL_Label
                   + "."
                   + Db.Label.urutan
                   + " asc",
               new String[] {
                 String.valueOf(bukmak2_id)
               }); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
   try {
     while (cursor.moveToNext()) {
       if (res == null) res = new ArrayList<Label>();
       res.add(Label.fromCursor(cursor));
     }
   } finally {
     cursor.close();
   }
   return res;
 }
Exemplo n.º 3
0
 public Label getLabelById(long labelId) {
   SQLiteDatabase db = helper.getReadableDatabase();
   Cursor cursor =
       db.query(
           Db.TABEL_Label,
           null,
           BaseColumns._ID + "=?",
           new String[] {String.valueOf(labelId)},
           null,
           null,
           null); //$NON-NLS-1$
   try {
     if (cursor.moveToNext()) {
       return Label.fromCursor(cursor);
     } else {
       return null;
     }
   } finally {
     cursor.close();
   }
 }
Exemplo n.º 4
0
 public List<Label> listSemuaLabel() {
   List<Label> res = new ArrayList<Label>();
   Cursor cursor =
       helper
           .getReadableDatabase()
           .query(
               Db.TABEL_Label,
               null,
               null,
               null,
               null,
               null,
               Db.Label.urutan + " asc"); // $NON-NLS-1$
   try {
     while (cursor.moveToNext()) {
       res.add(Label.fromCursor(cursor));
     }
   } finally {
     cursor.close();
   }
   return res;
 }
Exemplo n.º 5
0
 public void updateLabel(Label label) {
   SQLiteDatabase db = helper.getWritableDatabase();
   ContentValues cv = label.toContentValues();
   db.update(Db.TABEL_Label, cv, "_id=?", new String[] {String.valueOf(label._id)}); // $NON-NLS-1$
 }