Search in sources :

Example 6 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project Launcher3 by chislon.

the class LauncherProvider method update.

@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
    SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
    addModifiedTime(values);
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    int count = db.update(args.table, values, args.where, args.args);
    if (count > 0)
        sendNotify(uri);
    return count;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 7 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project Launcher3 by chislon.

the class LauncherProvider method bulkInsert.

@Override
public int bulkInsert(Uri uri, ContentValues[] values) {
    SqlArguments args = new SqlArguments(uri);
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    db.beginTransaction();
    try {
        int numValues = values.length;
        for (int i = 0; i < numValues; i++) {
            addModifiedTime(values[i]);
            if (dbInsertAndCheck(mOpenHelper, db, args.table, null, values[i]) < 0) {
                return 0;
            }
        }
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
    sendNotify(uri);
    return values.length;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 8 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project cw-omnibus by commonsguy.

the class DatabaseHelper method insertQuestions.

void insertQuestions(Context app, List<Item> items) {
    SQLiteDatabase db = getDb(app);
    db.beginTransaction();
    db.delete("questions", null, null);
    try {
        for (Item item : items) {
            Object[] args = { item.id, item.title, item.link, item.owner.profileImage, item.creationDate };
            db.execSQL("INSERT INTO questions (_id, title, " + "link, profileImage, creationDate) " + "VALUES (?, ?, ?, ?, ?)", args);
        }
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 9 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project philm by chrisbanes.

the class PhilmSQLiteOpenHelper method delete.

@Override
public void delete(Collection<PhilmMovie> movies) {
    assetNotClosed();
    SQLiteDatabase db = null;
    try {
        db = getWritableDatabase();
        db.beginTransaction();
        final DatabaseCompartment dbc = cupboard().withDatabase(db);
        for (PhilmMovie movie : movies) {
            dbc.delete(movie);
        }
        db.setTransactionSuccessful();
    } catch (Exception e) {
    // Crashlytics.logException(e);
    } finally {
        if (db != null) {
            db.endTransaction();
        }
    }
}
Also used : PhilmMovie(app.philm.in.model.PhilmMovie) DatabaseCompartment(nl.qbusict.cupboard.DatabaseCompartment) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 10 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project clutchandroid by clutchio.

the class ClutchStats method getCachedChoice.

public int getCachedChoice(String name) {
    int resp = -1;
    SQLiteDatabase db = getReadableDatabase();
    String[] args = { name };
    Cursor cur = db.rawQuery("SELECT choice FROM abcache WHERE name = ?", args);
    cur.moveToFirst();
    while (!cur.isAfterLast()) {
        resp = cur.getInt(0);
        cur.moveToNext();
    }
    db.close();
    return resp;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) 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