Exemplo n.º 1
0
 public void clearFeedTable() {
   String sql = "DELETE FROM " + SQLHelper.TABLE_CHANNEL + ";";
   SQLiteDatabase db = helper.getWritableDatabase();
   db.execSQL(sql);
   revertSeq();
   System.out.println("我是否删除");
 }
Exemplo n.º 2
0
 @Override
 public boolean updateCache(ContentValues values, String whereClause, String[] whereArgs) {
   // TODO Auto-generated method stub
   boolean flag = false;
   SQLiteDatabase database = null;
   int count = 0;
   try {
     database = helper.getWritableDatabase();
     count = database.update(SQLHelper.TABLE_CHANNEL, values, whereClause, whereArgs);
     flag = (count > 0 ? true : false);
   } catch (Exception e) {
     // TODO: handle exception
   } finally {
     if (database != null) {
       database.close();
     }
   }
   return flag;
 }
Exemplo n.º 3
0
 @Override
 public boolean addCache(ChannelItem item) {
   // TODO Auto-generated method stub
   boolean flag = false;
   SQLiteDatabase database = null;
   long id = -1;
   try {
     database = helper.getWritableDatabase();
     ContentValues values = new ContentValues();
     values.put("name", item.getName());
     values.put("id", item.getId());
     values.put("orderId", item.getOrderId());
     values.put("selected", item.getSelected());
     id = database.insert(SQLHelper.TABLE_CHANNEL, null, values);
     flag = (id != -1 ? true : false);
   } catch (Exception e) {
     // TODO: handle exception
   } finally {
     if (database != null) {
       database.close();
     }
   }
   return flag;
 }
Exemplo n.º 4
0
 private void revertSeq() {
   String sql = "update sqlite_sequence set seq=0 where name='" + SQLHelper.TABLE_CHANNEL + "'";
   SQLiteDatabase db = helper.getWritableDatabase();
   db.execSQL(sql);
 }