예제 #1
0
 public int toggleCellGroup(CellGroup group) {
   ContentValues content = new ContentValues();
   content.put(
       "status",
       group.getStatus() == CellGroup.STATUS.ENABLED.getValue()
           ? CellGroup.STATUS.DISABLED.getValue()
           : CellGroup.STATUS.ENABLED.getValue());
   return getWritableDatabase().update(CellGroup.NAME, content, "id=" + group.getId(), null);
 }
예제 #2
0
 public List<Cellular> readCellular(String type) {
   List<Cellular> list;
   Cursor cursor = null;
   try {
     cursor =
         getReadableDatabase()
             .rawQuery(
                 "SELECT c.id, c.mcc, c.mnc, c.lac, c.cid, c.lat, c.lon, c.status, c.cellgroup FROM CELLULAR c, CELL_GROUP g where c.cellgroup = g.id and g.status = "
                     + CellGroup.STATUS.ENABLED.getValue()
                     + " and g.type='"
                     + type
                     + "'",
                 null);
     list = new ArrayList<>(cursor.getCount());
     if (cursor.getCount() > 0) {
       cursor.moveToFirst();
       do {
         Cellular p =
             new Cellular(
                 cursor.getInt(1),
                 cursor.getInt(2),
                 cursor.getInt(3),
                 cursor.getInt(4),
                 cursor.getDouble(5),
                 cursor.getDouble(6),
                 cursor.getInt(7),
                 cursor.getInt(8));
         p.setId(cursor.getInt(0));
         list.add(p);
       } while (cursor.moveToNext());
     }
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
   return list;
 }