Search in sources :

Example 31 with SQLiteDatabase

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

the class DatabaseBackend method insertDiscoveryResult.

public void insertDiscoveryResult(ServiceDiscoveryResult result) {
    SQLiteDatabase db = this.getWritableDatabase();
    db.insert(ServiceDiscoveryResult.TABLENAME, null, result.getContentValues());
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 32 with SQLiteDatabase

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

the class DatabaseBackend method getConversations.

public CopyOnWriteArrayList<Conversation> getConversations(int status) {
    CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<>();
    SQLiteDatabase db = this.getReadableDatabase();
    String[] selectionArgs = { Integer.toString(status) };
    Cursor cursor = db.rawQuery("select * from " + Conversation.TABLENAME + " where " + Conversation.STATUS + " = ? order by " + Conversation.CREATED + " desc", selectionArgs);
    while (cursor.moveToNext()) {
        list.add(Conversation.fromCursor(cursor));
    }
    cursor.close();
    return list;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Conversation(eu.siacs.conversations.entities.Conversation) Cursor(android.database.Cursor) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 33 with SQLiteDatabase

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

the class DatabaseBackend method getCursorForSession.

private Cursor getCursorForSession(Account account, AxolotlAddress contact) {
    final SQLiteDatabase db = this.getReadableDatabase();
    String[] selectionArgs = { account.getUuid(), contact.getName(), Integer.toString(contact.getDeviceId()) };
    return db.query(SQLiteAxolotlStore.SESSION_TABLENAME, null, SQLiteAxolotlStore.ACCOUNT + " = ? AND " + SQLiteAxolotlStore.NAME + " = ? AND " + SQLiteAxolotlStore.DEVICE_ID + " = ? ", selectionArgs, null, null, null);
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 34 with SQLiteDatabase

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

the class DatabaseBackend method updateAccount.

public boolean updateAccount(Account account) {
    SQLiteDatabase db = this.getWritableDatabase();
    String[] args = { account.getUuid() };
    final int rows = db.update(Account.TABLENAME, account.getContentValues(), Account.UUID + "=?", args);
    return rows == 1;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

Example 35 with SQLiteDatabase

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

the class DatabaseBackend method storePreKey.

public void storePreKey(Account account, PreKeyRecord record) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(SQLiteAxolotlStore.ID, record.getId());
    values.put(SQLiteAxolotlStore.KEY, Base64.encodeToString(record.serialize(), Base64.DEFAULT));
    values.put(SQLiteAxolotlStore.ACCOUNT, account.getUuid());
    db.insert(SQLiteAxolotlStore.PREKEY_TABLENAME, null, values);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase)

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