Search in sources :

Example 11 with SQLiteDatabase

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();
}
Also used : JSONObject(org.json.JSONObject) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) JSONObject(org.json.JSONObject)

Example 12 with SQLiteDatabase

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;
}
Also used : JSONObject(org.json.JSONObject) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) Cursor(android.database.Cursor)

Example 13 with SQLiteDatabase

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();
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) JSONObject(org.json.JSONObject)

Example 14 with SQLiteDatabase

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);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Bundle(android.os.Bundle) Cursor(android.database.Cursor)

Example 15 with SQLiteDatabase

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);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Bundle(android.os.Bundle) Cursor(android.database.Cursor)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1553 Cursor (android.database.Cursor)499 ContentValues (android.content.ContentValues)321 ArrayList (java.util.ArrayList)105 File (java.io.File)65 Test (org.junit.Test)57 SQLiteException (android.database.sqlite.SQLiteException)45 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)44 Uri (android.net.Uri)44 ServiceStatus (com.vodafone360.people.service.ServiceStatus)42 IOException (java.io.IOException)41 SQLException (android.database.SQLException)36 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)36 RemoteException (android.os.RemoteException)36 Pair (android.util.Pair)31 MediumTest (android.test.suitebuilder.annotation.MediumTest)30 Account (android.accounts.Account)29 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)25 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)22 HashMap (java.util.HashMap)21