Search in sources :

Example 21 with SQLiteQueryBuilder

use of android.database.sqlite.SQLiteQueryBuilder in project storymaker by StoryMaker.

the class Table method queryAll.

public Cursor queryAll(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(getTableName());
    Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(context.getContentResolver(), uri);
    return cursor;
}
Also used : Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder)

Example 22 with SQLiteQueryBuilder

use of android.database.sqlite.SQLiteQueryBuilder in project storymaker by StoryMaker.

the class Table method queryAllDistinct.

public Cursor queryAllDistinct(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(getTableName());
    // "true" specifies distinct results
    queryBuilder.setDistinct(true);
    Cursor cursor = queryBuilder.query(mDB, projection, selection, selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(context.getContentResolver(), uri);
    return cursor;
}
Also used : Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder)

Example 23 with SQLiteQueryBuilder

use of android.database.sqlite.SQLiteQueryBuilder in project SunDay by iQuick.

the class DataProvider method query.

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    synchronized (DBLock) {
        SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
        String table = matchTable(uri);
        queryBuilder.setTables(table);
        SQLiteDatabase db = getDBHelper().getReadableDatabase();
        //            Cursor cursor = query(uri, projection, selection, selectionArgs, sortOrder);
        Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
        cursor.setNotificationUri(getContext().getContentResolver(), uri);
        return cursor;
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder)

Example 24 with SQLiteQueryBuilder

use of android.database.sqlite.SQLiteQueryBuilder in project android_packages_apps_Launcher2 by CyanogenMod.

the class LauncherProvider method query.

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SqlArguments args = new SqlArguments(uri, selection, selectionArgs);
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(args.table);
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    Cursor result = qb.query(db, projection, args.where, args.args, null, null, sortOrder);
    result.setNotificationUri(getContext().getContentResolver(), uri);
    return result;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder)

Example 25 with SQLiteQueryBuilder

use of android.database.sqlite.SQLiteQueryBuilder in project android_frameworks_base by DirtyUnicorns.

the class LocalProvider method query.

@Override
public Cursor query(Uri url, String[] projectionIn, String selection, String[] selectionArgs, String sort) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    // Generate the body of the query
    int match = sURLMatcher.match(url);
    switch(match) {
        case DATA:
            qb.setTables("data");
            break;
        case DATA_ID:
            qb.setTables("data");
            qb.appendWhere("_id=");
            qb.appendWhere(url.getPathSegments().get(1));
            break;
        default:
            throw new IllegalArgumentException("Unknown URL " + url);
    }
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
    if (ret == null) {
        if (false)
            Log.d(TAG, "Alarms.query: failed");
    } else {
        ret.setNotificationUri(getContext().getContentResolver(), url);
    }
    return ret;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder)

Aggregations

SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)106 Cursor (android.database.Cursor)93 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)44 ContentValues (android.content.ContentValues)8 Account (android.accounts.Account)7 SQLiteException (android.database.sqlite.SQLiteException)7 File (java.io.File)7 HashMap (java.util.HashMap)7 SyncStatusInfo (android.content.SyncStatusInfo)6 MatrixCursor (android.database.MatrixCursor)5 RowBuilder (android.database.MatrixCursor.RowBuilder)5 ContentResolver (android.content.ContentResolver)4 Test (org.junit.Test)2 Matchers.anyLong (org.mockito.Matchers.anyLong)2 Returns (org.mockito.internal.stubbing.answers.Returns)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 AbstractCursor (android.database.AbstractCursor)1 MergeCursor (android.database.MergeCursor)1 AtomicFile (android.util.AtomicFile)1 AtomicFile (com.android.internal.os.AtomicFile)1