Search in sources :

Example 46 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project AsmackService by rtreffer.

the class Database method hasFeature.

/**
     * Check if a given feature is enabled for a single account or globally.
     * @param context The current context.
     * @param feature The feature to test.
     * @param jid The account jid.
     * @param factory A cursor factory (may be null).
     * @return True if the feature is available.
     */
public static synchronized boolean hasFeature(Context context, String feature, String jid, CursorFactory factory) {
    SQLiteDatabase database = getDatabase(context, factory);
    boolean featureAvailable = false;
    if (jid == null) {
        Cursor result = database.query("feature", new String[] { "_id" }, "(jid IS NULL) AND ver=?", new String[] { feature }, null, null, null);
        featureAvailable = result.getCount() > 0;
        result.close();
    } else {
        Cursor result = database.query("feature", new String[] { "_id" }, "(jid=? OR (jid IS NULL)) AND ver=?", new String[] { jid, feature }, null, null, null);
        featureAvailable = result.getCount() > 0;
        result.close();
    }
    return featureAvailable;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 47 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project AsmackService by rtreffer.

the class Database method enableFeature.

/***
     * Enable a feature for a given account.
     * @param context The current context.
     * @param feature The feature to enable.
     * @param jid The account jid.
     * @param factory A cursor factory (may be null).
     */
public static synchronized void enableFeature(Context context, String feature, String jid, CursorFactory factory) {
    if (hasFeature(context, feature, jid, factory)) {
        return;
    }
    SQLiteDatabase database = getDatabase(context, factory);
    ContentValues values = new ContentValues();
    if (jid != null) {
        values.put("jid", jid);
    }
    values.put("ver", feature);
    database.insert("feature", "_id", values);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 48 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.

the class TrackerProvider method delete.

@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    int result = db.delete(TABLE_NAME, selection, selectionArgs);
    getContext().getContentResolver().notifyChange(uri, null);
    return result;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 49 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.

the class TrackerProvider method query.

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    // TODO: extract limit from URI ?
    Cursor cursor = db.query(TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
    getContext().getContentResolver().notifyChange(uri, null);
    return cursor;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 50 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project platform_frameworks_base by android.

the class TrackerProvider method insert.

@Override
public Uri insert(Uri uri, ContentValues values) {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    long rowId = db.insert(TABLE_NAME, null, values);
    if (rowId > 0) {
        Uri addedUri = ContentUris.withAppendedId(CONTENT_URI, rowId);
        getContext().getContentResolver().notifyChange(addedUri, null);
        return addedUri;
    }
    return null;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Uri(android.net.Uri)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1658 Cursor (android.database.Cursor)527 ContentValues (android.content.ContentValues)350 ArrayList (java.util.ArrayList)111 File (java.io.File)65 Test (org.junit.Test)59 SQLiteException (android.database.sqlite.SQLiteException)48 SQLException (android.database.SQLException)44 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)44 Uri (android.net.Uri)44 IOException (java.io.IOException)43 ServiceStatus (com.vodafone360.people.service.ServiceStatus)42 SQLiteOpenHelper (android.database.sqlite.SQLiteOpenHelper)38 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