Search in sources :

Example 66 with SQLiteDatabase

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

the class GroupReceiptDatabase method deleteAllRows.

void deleteAllRows() {
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.delete(TABLE_NAME, null, null);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 67 with SQLiteDatabase

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

the class GroupReceiptDatabase method insert.

public void insert(List<Address> addresses, long mmsId, int status, long timestamp) {
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    for (Address address : addresses) {
        ContentValues values = new ContentValues(4);
        values.put(MMS_ID, mmsId);
        values.put(ADDRESS, address.serialize());
        values.put(STATUS, status);
        values.put(TIMESTAMP, timestamp);
        db.insert(TABLE_NAME, null, values);
    }
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 68 with SQLiteDatabase

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

the class GroupReceiptDatabase method deleteRowsForMessage.

void deleteRowsForMessage(long mmsId) {
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.delete(TABLE_NAME, MMS_ID + " = ?", new String[] { String.valueOf(mmsId) });
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 69 with SQLiteDatabase

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

the class IdentityDatabase method saveIdentity.

public void saveIdentity(Address address, IdentityKey identityKey, VerifiedStatus verifiedStatus, boolean firstUse, long timestamp, boolean nonBlockingApproval) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    String identityKeyString = Base64.encodeBytes(identityKey.serialize());
    ContentValues contentValues = new ContentValues();
    contentValues.put(ADDRESS, address.serialize());
    contentValues.put(IDENTITY_KEY, identityKeyString);
    contentValues.put(TIMESTAMP, timestamp);
    contentValues.put(VERIFIED, verifiedStatus.toInt());
    contentValues.put(NONBLOCKING_APPROVAL, nonBlockingApproval ? 1 : 0);
    contentValues.put(FIRST_USE, firstUse ? 1 : 0);
    database.replace(TABLE_NAME, null, contentValues);
    EventBus.getDefault().post(new IdentityRecord(address, identityKey, verifiedStatus, firstUse, timestamp, nonBlockingApproval));
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 70 with SQLiteDatabase

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

the class IdentityDatabase method setVerified.

public void setVerified(Address address, IdentityKey identityKey, VerifiedStatus verifiedStatus) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    ContentValues contentValues = new ContentValues(1);
    contentValues.put(VERIFIED, verifiedStatus.toInt());
    int updated = database.update(TABLE_NAME, contentValues, ADDRESS + " = ? AND " + IDENTITY_KEY + " = ?", new String[] { address.serialize(), Base64.encodeBytes(identityKey.serialize()) });
    if (updated > 0) {
        Optional<IdentityRecord> record = getIdentity(address);
        if (record.isPresent())
            EventBus.getDefault().post(record.get());
    }
}
Also used : ContentValues(android.content.ContentValues) 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