Search in sources :

Example 41 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project Conversations by siacs.

the class DatabaseBackend method storePreVerification.

public void storePreVerification(Account account, String name, String fingerprint, FingerprintStatus status) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(SQLiteAxolotlStore.ACCOUNT, account.getUuid());
    values.put(SQLiteAxolotlStore.NAME, name);
    values.put(SQLiteAxolotlStore.OWN, 0);
    values.put(SQLiteAxolotlStore.FINGERPRINT, fingerprint);
    values.putAll(status.toContentValues());
    db.insert(SQLiteAxolotlStore.IDENTITIES_TABLENAME, null, values);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 42 with SQLiteDatabase

use of android.database.sqlite.SQLiteDatabase in project Conversations by siacs.

the class DatabaseBackend method numTrustedKeys.

public long numTrustedKeys(Account account, String name) {
    SQLiteDatabase db = getReadableDatabase();
    String[] args = { account.getUuid(), name, FingerprintStatus.Trust.TRUSTED.toString(), FingerprintStatus.Trust.VERIFIED.toString(), FingerprintStatus.Trust.VERIFIED_X509.toString() };
    return DatabaseUtils.queryNumEntries(db, SQLiteAxolotlStore.IDENTITIES_TABLENAME, SQLiteAxolotlStore.ACCOUNT + " = ?" + " AND " + SQLiteAxolotlStore.NAME + " = ?" + " AND (" + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ? OR " + SQLiteAxolotlStore.TRUST + " = ?)" + " AND " + SQLiteAxolotlStore.ACTIVE + " > 0", args);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 43 with SQLiteDatabase

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

the class Database method hasIdentity.

/**
     * Check if a xmpp identity is available for a given account.
     * @param context The current context.
     * @param identity The xmpp identity.
     * @param jid The account jid.
     * @param factory A cursor factory (may be null).
     * @return True if the identity is available.
     */
public static synchronized boolean hasIdentity(Context context, XmppIdentity identity, String jid, CursorFactory factory) {
    SQLiteDatabase database = getDatabase(context, factory);
    Cursor result = database.query("feature", new String[] { "_id" }, "(jid=? OR (jid IS NULL)) AND " + "category=? AND type=? AND lang=? AND name=?", new String[] { jid, identity.getCategory(), identity.getType(), identity.getLang(), identity.getName() }, null, null, null);
    boolean identityAvailable = result.getCount() > 0;
    result.close();
    return identityAvailable;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Cursor(android.database.Cursor)

Example 44 with SQLiteDatabase

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

the class Database method addIdentity.

/**
     * Add a xmpp identity to a given account.
     * @param context The current context.
     * @param identity The xmpp identity.
     * @param jid The account jid.
     * @param factory A cursor factory (may be null).
     */
public static synchronized void addIdentity(Context context, String jid, XmppIdentity identity, CursorFactory factory) {
    if (hasIdentity(context, identity, jid, factory)) {
        return;
    }
    SQLiteDatabase database = getDatabase(context, factory);
    ContentValues values = new ContentValues();
    if (jid != null) {
        values.put("jid", jid);
    }
    values.put("category", identity.getCategory());
    values.put("type", identity.getType());
    values.put("lang", identity.getLang());
    values.put("name", identity.getName());
    database.insert("identity", "_id", values);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 45 with SQLiteDatabase

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

the class Database method getFeatures.

/**
     * Retrieve a list of all features enabled on a given connection.
     * @param context The current context.
     * @param jid The user jid.
     * @param factory A cursor factory (may be null).
     * @return An array of enabled features.
     */
public static synchronized String[] getFeatures(Context context, String jid, CursorFactory factory) {
    ArrayList<String> features = new ArrayList<String>();
    SQLiteDatabase database = getDatabase(context, factory);
    Cursor result = database.query(true, "feature", new String[] { "ver" }, "(jid=? OR (jid IS NULL))", new String[] { jid }, null, null, "ver ASC", null);
    features.ensureCapacity(result.getCount() + 1);
    if (result.getCount() > 0) {
        int verId = result.getColumnIndex("ver");
        result.moveToFirst();
        do {
            features.add(result.getString(verId));
            result.moveToNext();
        } while (!result.isAfterLast());
    }
    result.close();
    String[] output = new String[features.size()];
    return features.toArray(output);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

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