use of android.database.sqlite.SQLiteDatabase in project clutchandroid by clutchio.
the class ClutchStats method logAction.
public void logAction(String action, Map<String, ?> data) {
SQLiteDatabase db = getWritableDatabase();
Object[] args = { ClutchUtils.getUUID(), System.currentTimeMillis() / 1000.0, action, new JSONObject(data).toString() };
db.execSQL("INSERT INTO stats (uuid, ts, action, data) VALUES (?, ?, ?, ?)", args);
db.close();
}
use of android.database.sqlite.SQLiteDatabase in project clutchandroid by clutchio.
the class ClutchStats method getABLogs.
public ArrayList<ABRow> getABLogs() {
SQLiteDatabase db = getReadableDatabase();
String[] args = {};
ArrayList<ABRow> res = new ArrayList<ABRow>();
Cursor cur = db.rawQuery("SELECT uuid, ts, data FROM ablog ORDER BY ts", args);
cur.moveToFirst();
while (!cur.isAfterLast()) {
String uuid = cur.getString(0);
double ts = cur.getDouble(1);
JSONObject data;
try {
data = new JSONObject(cur.getString(2));
} catch (JSONException e) {
Log.w(TAG, "Could not serialize to JSON: " + cur.getString(3));
cur.moveToNext();
continue;
}
res.add(new ABRow(uuid, ts, data));
cur.moveToNext();
}
db.close();
return res;
}
use of android.database.sqlite.SQLiteDatabase in project clutchandroid by clutchio.
the class ClutchStats method deleteABLogs.
public void deleteABLogs(double ts) {
SQLiteDatabase db = this.getWritableDatabase();
Object[] args = { ts };
db.execSQL("DELETE FROM ablog WHERE ts <= ?", args);
db.close();
}
use of android.database.sqlite.SQLiteDatabase in project cw-advandroid by commonsguy.
the class SQLiteInterpreter method executeScript.
public Bundle executeScript(Bundle input) {
Bundle result = new Bundle(input);
String script = input.getString(InterpreterService.SCRIPT);
if (script != null) {
SQLiteDatabase db = SQLiteDatabase.create(null);
Cursor c = db.rawQuery(script, null);
c.moveToFirst();
for (int i = 0; i < c.getColumnCount(); i++) {
result.putString(c.getColumnName(i), c.getString(i));
}
c.close();
db.close();
}
return (result);
}
use of android.database.sqlite.SQLiteDatabase in project cw-omnibus by commonsguy.
the class SQLiteInterpreter method executeScript.
public Bundle executeScript(Bundle input) {
Bundle result = new Bundle(input);
String script = input.getString(InterpreterService.SCRIPT);
if (script != null) {
SQLiteDatabase db = SQLiteDatabase.create(null);
Cursor c = db.rawQuery(script, null);
c.moveToFirst();
for (int i = 0; i < c.getColumnCount(); i++) {
result.putString(c.getColumnName(i), c.getString(i));
}
c.close();
db.close();
}
return (result);
}
Aggregations