示例#1
0
 public static ArrayList<LogEntry> getLogs(Context context, UidPolicy policy, int limit) {
   ArrayList<LogEntry> ret = new ArrayList<LogEntry>();
   SQLiteDatabase db = new SuDatabaseHelper(context).getReadableDatabase();
   Cursor c;
   if (policy.command != null)
     c =
         db.query(
             "log",
             null,
             "uid = ? and desired_uid = ? and command = ?",
             new String[] {
               String.valueOf(policy.uid), String.valueOf(policy.desiredUid), policy.command
             },
             null,
             null,
             "date DESC",
             limit == -1 ? null : String.valueOf(limit));
   else
     c =
         db.query(
             "log",
             null,
             "uid = ? and desired_uid = ?",
             new String[] {String.valueOf(policy.uid), String.valueOf(policy.desiredUid)},
             null,
             null,
             "date DESC",
             limit == -1 ? null : String.valueOf(limit));
   try {
     while (c.moveToNext()) {
       LogEntry l = new LogEntry();
       ret.add(l);
       getUidCommand(c, l);
       l.id = c.getLong(c.getColumnIndex("id"));
       l.date = c.getInt(c.getColumnIndex("date"));
       l.action = c.getString(c.getColumnIndex("action"));
     }
   } catch (Exception ex) {
   } finally {
     c.close();
     db.close();
   }
   return ret;
 }
示例#2
0
 public static ArrayList<LogEntry> getLogs(Context context) {
   ArrayList<LogEntry> ret = new ArrayList<LogEntry>();
   SQLiteDatabase db = new SuDatabaseHelper(context).getReadableDatabase();
   Cursor c = db.query("log", null, null, null, null, null, "date DESC");
   try {
     while (c.moveToNext()) {
       LogEntry l = new LogEntry();
       ret.add(l);
       getUidCommand(c, l);
       l.id = c.getLong(c.getColumnIndex("id"));
       l.date = c.getInt(c.getColumnIndex("date"));
       l.action = c.getString(c.getColumnIndex("action"));
     }
   } catch (Exception ex) {
   } finally {
     c.close();
     db.close();
   }
   return ret;
 }