Search in sources :

Example 41 with ContentValues

use of android.content.ContentValues in project qksms by moezbhatti.

the class Message method markRead.

public void markRead() {
    ContentValues cv = new ContentValues();
    cv.put("read", true);
    cv.put("seen", true);
    if (isMms()) {
        context.getContentResolver().update(Uri.parse("content://mms/" + getId()), cv, null, null);
    } else {
        context.getContentResolver().update(Uri.parse("content://sms/" + getId()), cv, null, null);
    }
}
Also used : ContentValues(android.content.ContentValues)

Example 42 with ContentValues

use of android.content.ContentValues in project qksms by moezbhatti.

the class Message method markSeen.

public void markSeen() {
    ContentValues cv = new ContentValues();
    cv.put("seen", true);
    if (isMms()) {
        context.getContentResolver().update(Uri.parse("content://mms/" + getId()), cv, null, null);
    } else {
        context.getContentResolver().update(Uri.parse("content://sms/" + getId()), cv, null, null);
    }
}
Also used : ContentValues(android.content.ContentValues)

Example 43 with ContentValues

use of android.content.ContentValues in project qksms by moezbhatti.

the class SmsHelper method markMmsSeen.

public static void markMmsSeen(Context context) {
    Cursor cursor = context.getContentResolver().query(MMS_CONTENT_PROVIDER, new String[] { SmsHelper.COLUMN_ID }, SmsHelper.UNSEEN_SELECTION + " AND " + SmsHelper.UNREAD_SELECTION, null, null);
    if (cursor == null) {
        Log.i(TAG, "No unseen messages");
        return;
    }
    MessageColumns.ColumnsMap map = new MessageColumns.ColumnsMap(cursor);
    if (cursor.moveToFirst()) {
        ContentValues cv = new ContentValues();
        cv.put("seen", true);
        do {
            context.getContentResolver().update(Uri.parse("content://mms/" + cursor.getLong(map.mColumnMsgId)), cv, null, null);
        } while (cursor.moveToNext());
    }
    cursor.close();
}
Also used : ContentValues(android.content.ContentValues) Cursor(android.database.Cursor) MessageColumns(com.moez.QKSMS.ui.messagelist.MessageColumns)

Example 44 with ContentValues

use of android.content.ContentValues in project qksms by moezbhatti.

the class SmsHelper method markSmsSeen.

public static void markSmsSeen(Context context) {
    Cursor cursor = context.getContentResolver().query(RECEIVED_MESSAGE_CONTENT_PROVIDER, new String[] { SmsHelper.COLUMN_ID }, SmsHelper.UNSEEN_SELECTION + " AND " + SmsHelper.UNREAD_SELECTION, null, null);
    if (cursor == null) {
        Log.i(TAG, "No unseen messages");
        return;
    }
    MessageColumns.ColumnsMap map = new MessageColumns.ColumnsMap(cursor);
    if (cursor.moveToFirst()) {
        ContentValues cv = new ContentValues();
        cv.put("seen", true);
        do {
            context.getContentResolver().update(Uri.parse("content://sms/" + cursor.getLong(map.mColumnMsgId)), cv, null, null);
        } while (cursor.moveToNext());
    }
    cursor.close();
}
Also used : ContentValues(android.content.ContentValues) Cursor(android.database.Cursor) MessageColumns(com.moez.QKSMS.ui.messagelist.MessageColumns)

Example 45 with ContentValues

use of android.content.ContentValues in project Signal-Android by WhisperSystems.

the class AttachmentDatabase method insertAttachmentsForPlaceholder.

public long insertAttachmentsForPlaceholder(@NonNull MasterSecret masterSecret, long mmsId, @NonNull AttachmentId attachmentId, @NonNull InputStream inputStream) throws MmsException {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    Pair<File, Long> partData = setAttachmentData(masterSecret, inputStream);
    ContentValues values = new ContentValues();
    values.put(DATA, partData.first.getAbsolutePath());
    values.put(SIZE, partData.second);
    values.put(TRANSFER_STATE, TRANSFER_PROGRESS_DONE);
    values.put(CONTENT_LOCATION, (String) null);
    values.put(CONTENT_DISPOSITION, (String) null);
    values.put(DIGEST, (byte[]) null);
    values.put(NAME, (String) null);
    if (database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings()) == 0) {
        //noinspection ResultOfMethodCallIgnored
        partData.first.delete();
    } else {
        notifyConversationListeners(DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(mmsId));
        notifyConversationListListeners();
    }
    thumbnailExecutor.submit(new ThumbnailFetchCallable(masterSecret, attachmentId));
    return partData.second;
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) File(java.io.File)

Aggregations

ContentValues (android.content.ContentValues)4022 Cursor (android.database.Cursor)721 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)638 Uri (android.net.Uri)619 Test (org.junit.Test)374 SQLException (android.database.SQLException)231 ContentResolver (android.content.ContentResolver)212 ArrayList (java.util.ArrayList)192 Intent (android.content.Intent)163 File (java.io.File)156 IOException (java.io.IOException)131 RemoteException (android.os.RemoteException)96 CursorAssert.assertThatCursor (org.hisp.dhis.android.core.data.database.CursorAssert.assertThatCursor)91 NonNull (android.support.annotation.NonNull)74 Date (java.util.Date)73 MediumTest (android.test.suitebuilder.annotation.MediumTest)63 HashMap (java.util.HashMap)62 JSONException (org.json.JSONException)60 SQLiteConstraintException (android.database.sqlite.SQLiteConstraintException)55 SQLiteException (android.database.sqlite.SQLiteException)53