Search in sources :

Example 31 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.

the class SessionDatabase method delete.

public void delete(@NonNull Address address, int deviceId) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    database.delete(TABLE_NAME, ADDRESS + " = ? AND " + DEVICE + " = ?", new String[] { address.serialize(), String.valueOf(deviceId) });
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 32 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.

the class SessionDatabase method getSubDevices.

@NonNull
public List<Integer> getSubDevices(@NonNull Address address) {
    SQLiteDatabase database = databaseHelper.getReadableDatabase();
    List<Integer> results = new LinkedList<>();
    try (Cursor cursor = database.query(TABLE_NAME, new String[] { DEVICE }, ADDRESS + " = ?", new String[] { address.serialize() }, null, null, null)) {
        while (cursor != null && cursor.moveToNext()) {
            int device = cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE));
            if (device != SignalServiceAddress.DEFAULT_DEVICE_ID) {
                results.add(device);
            }
        }
    }
    return results;
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) Cursor(android.database.Cursor) LinkedList(java.util.LinkedList) NonNull(android.support.annotation.NonNull)

Example 33 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.

the class SessionDatabase method store.

public void store(@NonNull Address address, int deviceId, @NonNull SessionRecord record) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(ADDRESS, address.serialize());
    values.put(DEVICE, deviceId);
    values.put(RECORD, record.serialize());
    database.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 34 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.

the class SessionDatabase method getAll.

@NonNull
public List<SessionRow> getAll() {
    SQLiteDatabase database = databaseHelper.getReadableDatabase();
    List<SessionRow> results = new LinkedList<>();
    try (Cursor cursor = database.query(TABLE_NAME, null, null, null, null, null, null)) {
        while (cursor != null && cursor.moveToNext()) {
            try {
                results.add(new SessionRow(Address.fromSerialized(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS))), cursor.getInt(cursor.getColumnIndexOrThrow(DEVICE)), new SessionRecord(cursor.getBlob(cursor.getColumnIndexOrThrow(RECORD)))));
            } catch (IOException e) {
                Log.w(TAG, e);
            }
        }
    }
    return results;
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) IOException(java.io.IOException) Cursor(android.database.Cursor) LinkedList(java.util.LinkedList) SessionRecord(org.whispersystems.libsignal.state.SessionRecord) NonNull(android.support.annotation.NonNull)

Example 35 with SQLiteDatabase

use of net.sqlcipher.database.SQLiteDatabase in project Signal-Android by signalapp.

the class SessionDatabase method deleteAllFor.

public void deleteAllFor(@NonNull Address address) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    database.delete(TABLE_NAME, ADDRESS + " = ?", new String[] { address.serialize() });
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Aggregations

SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)124 Cursor (android.database.Cursor)37 ContentValues (android.content.ContentValues)32 IOException (java.io.IOException)15 LinkedList (java.util.LinkedList)12 NonNull (android.support.annotation.NonNull)7 MergeCursor (android.database.MergeCursor)6 Nullable (android.support.annotation.Nullable)6 Pair (android.util.Pair)6 File (java.io.File)5 SQLiteConstraintException (net.sqlcipher.database.SQLiteConstraintException)5 FileNotFoundException (java.io.FileNotFoundException)4 StreamCorruptedException (java.io.StreamCorruptedException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 AudioClipTable (org.storymaker.app.model.AudioClipTable)4 AuthTable (org.storymaker.app.model.AuthTable)4 JobTable (org.storymaker.app.model.JobTable)4 LessonTable (org.storymaker.app.model.LessonTable)4 MediaTable (org.storymaker.app.model.MediaTable)4 ProjectTable (org.storymaker.app.model.ProjectTable)4