Search in sources :

Example 91 with SQLiteDatabase

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

the class SmsDatabase method getOutgoingMessages.

Cursor getOutgoingMessages() {
    String outgoingSelection = TYPE + " & " + Types.BASE_TYPE_MASK + " = " + Types.BASE_OUTBOX_TYPE;
    SQLiteDatabase db = databaseHelper.getReadableDatabase();
    return db.query(TABLE_NAME, MESSAGE_PROJECTION, outgoingSelection, null, null, null, null);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 92 with SQLiteDatabase

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

the class SmsDatabase method deleteMessagesInThreadBeforeDate.

/*package*/
void deleteMessagesInThreadBeforeDate(long threadId, long date) {
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    String where = THREAD_ID + " = ? AND (CASE " + TYPE;
    for (long outgoingType : Types.OUTGOING_MESSAGE_TYPES) {
        where += " WHEN " + outgoingType + " THEN " + DATE_SENT + " < " + date;
    }
    where += (" ELSE " + DATE_RECEIVED + " < " + date + " END)");
    db.delete(TABLE_NAME, where, new String[] { threadId + "" });
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 93 with SQLiteDatabase

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

the class SmsDatabase method deleteMessage.

public boolean deleteMessage(long messageId) {
    Log.w("MessageDatabase", "Deleting: " + messageId);
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    long threadId = getThreadIdForMessage(messageId);
    db.delete(TABLE_NAME, ID_WHERE, new String[] { messageId + "" });
    boolean threadDeleted = DatabaseFactory.getThreadDatabase(context).update(threadId, false);
    notifyConversationListeners(threadId);
    return threadDeleted;
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 94 with SQLiteDatabase

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

the class SmsDatabase method getExpirationStartedMessages.

public Cursor getExpirationStartedMessages() {
    String where = EXPIRE_STARTED + " > 0";
    SQLiteDatabase db = databaseHelper.getReadableDatabase();
    return db.query(TABLE_NAME, MESSAGE_PROJECTION, where, null, null, null, null);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase)

Example 95 with SQLiteDatabase

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

the class SmsDatabase method updateMessageBodyAndType.

private Pair<Long, Long> updateMessageBodyAndType(long messageId, String body, long maskOff, long maskOn) {
    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    db.execSQL("UPDATE " + TABLE_NAME + " SET " + BODY + " = ?, " + TYPE + " = (" + TYPE + " & " + (Types.TOTAL_MASK - maskOff) + " | " + maskOn + ") " + "WHERE " + ID + " = ?", new String[] { body, messageId + "" });
    long threadId = getThreadIdForMessage(messageId);
    DatabaseFactory.getThreadDatabase(context).update(threadId, true);
    notifyConversationListeners(threadId);
    notifyConversationListListeners();
    return new Pair<>(messageId, threadId);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) Pair(android.util.Pair)

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