/** * 查询全部的锁定的包名 * * @return */ public List<String> findAll() { SQLiteDatabase db = helper.getReadableDatabase(); Cursor cursor = db.query("info", new String[] {"packagename"}, null, null, null, null, null); List<String> packnames = new ArrayList<String>(); while (cursor.moveToNext()) { packnames.add(cursor.getString(0)); } cursor.close(); db.close(); return packnames; }
/** * 查询当前的包是否在程序锁里面 * * @param packageName * @return */ public boolean find(String packageName) { boolean result = false; SQLiteDatabase db = helper.getReadableDatabase(); Cursor cursor = db.query("info", null, "packagename=?", new String[] {packageName}, null, null, null); if (cursor.moveToNext()) { result = true; } cursor.close(); db.close(); return result; }