Example #1
0
 /** 查询全部的黑名单号码 */
 public List<BlackNumberInfo> findAll() {
   // 得到可读的数据库
   SQLiteDatabase db = helper.getReadableDatabase();
   Cursor cursor =
       db.query("blackinfo", new String[] {"number", "mode"}, null, null, null, null, null);
   List<BlackNumberInfo> blackNumberInfos = new ArrayList<BlackNumberInfo>();
   while (cursor.moveToNext()) {
     BlackNumberInfo info = new BlackNumberInfo();
     String number = cursor.getString(0);
     String mode = cursor.getString(1);
     info.setMode(mode);
     info.setNumber(number);
     blackNumberInfos.add(info);
   }
   cursor.close();
   db.close();
   SystemClock.sleep(3000);
   return blackNumberInfos;
 }
Example #2
0
 /**
  * 分批加载数据
  *
  * @param startIndex 从哪个位置开始加载数据
  * @param maxCount 最多加载几条数据
  */
 public List<BlackNumberInfo> findPart2(int startIndex, int maxCount) {
   // 得到可读的数据库
   SQLiteDatabase db = helper.getReadableDatabase();
   Cursor cursor =
       db.rawQuery(
           "select number,mode from blackinfo order by _id desc limit ? offset ?",
           new String[] {String.valueOf(maxCount), String.valueOf(startIndex)});
   List<BlackNumberInfo> blackNumberInfos = new ArrayList<BlackNumberInfo>();
   while (cursor.moveToNext()) {
     BlackNumberInfo info = new BlackNumberInfo();
     String number = cursor.getString(0);
     String mode = cursor.getString(1);
     info.setMode(mode);
     info.setNumber(number);
     blackNumberInfos.add(info);
   }
   cursor.close();
   db.close();
   SystemClock.sleep(30);
   return blackNumberInfos;
 }