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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations