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