use of android.content.ContentValues in project qksms by moezbhatti.
the class Conversation method blockingMarkAllMmsMessagesAsSeen.
private static void blockingMarkAllMmsMessagesAsSeen(final Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = resolver.query(Mms.Inbox.CONTENT_URI, SEEN_PROJECTION, "seen=0", null, null);
int count = 0;
if (cursor != null) {
try {
count = cursor.getCount();
} finally {
cursor.close();
}
}
if (count == 0) {
return;
}
if (DELETEDEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "mark " + count + " MMS msgs as seen");
}
ContentValues values = new ContentValues(1);
values.put("seen", 1);
resolver.update(Mms.Inbox.CONTENT_URI, values, "seen=0", null);
}
use of android.content.ContentValues in project qksms by moezbhatti.
the class RecipientIdCache method updateCanonicalAddressInDb.
private void updateCanonicalAddressInDb(long id, String number) {
if (LogTag.VERBOSE || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "[RecipientIdCache] updateCanonicalAddressInDb: id=" + id + ", number=" + number);
}
final ContentValues values = new ContentValues();
values.put(Telephony.CanonicalAddressesColumns.ADDRESS, number);
final StringBuilder buf = new StringBuilder(Telephony.CanonicalAddressesColumns._ID);
buf.append('=').append(id);
final Uri uri = ContentUris.withAppendedId(sSingleCanonicalAddressUri, id);
final ContentResolver cr = mContext.getContentResolver();
// We're running on the UI thread so just fire & forget, hope for the best.
// (We were ignoring the return value anyway...)
new Thread("updateCanonicalAddressInDb") {
public void run() {
cr.update(uri, values, buf.toString(), null);
}
}.start();
}
use of android.content.ContentValues in project qksms by moezbhatti.
the class Conversation method blockingMarkAllSmsMessagesAsSeen.
private static void blockingMarkAllSmsMessagesAsSeen(final Context context) {
ContentResolver resolver = context.getContentResolver();
Cursor cursor = resolver.query(Sms.Inbox.CONTENT_URI, SEEN_PROJECTION, "seen=0", null, null);
int count = 0;
if (cursor != null) {
try {
count = cursor.getCount();
} finally {
cursor.close();
}
}
if (count == 0) {
return;
}
if (DELETEDEBUG || Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
Log.d(TAG, "mark " + count + " SMS msgs as seen");
}
ContentValues values = new ContentValues(1);
values.put("seen", 1);
resolver.update(Sms.Inbox.CONTENT_URI, values, "seen=0", null);
}
use of android.content.ContentValues in project qksms by moezbhatti.
the class ConversationLegacy method saveDraft.
public void saveDraft(final String draft) {
clearDrafts();
if (draft.length() > 0) {
try {
DraftCache.getInstance().setSavingDraft(true);
DraftCache.getInstance().setDraftState(threadId, true);
ConversationLegacy.this.draft = draft;
ContentResolver contentResolver = context.getContentResolver();
ContentValues cv = new ContentValues();
cv.put("address", getAddress());
cv.put("body", draft);
contentResolver.insert(SmsHelper.DRAFTS_CONTENT_PROVIDER, cv);
} finally {
DraftCache.getInstance().setSavingDraft(false);
}
} else {
ConversationLegacy.this.draft = null;
}
Toast.makeText(context, R.string.toast_draft, Toast.LENGTH_SHORT).show();
}
use of android.content.ContentValues in project qksms by moezbhatti.
the class ConversationLegacy method markUnread.
public void markUnread() {
new DefaultSmsHelper(context, R.string.not_default_mark_unread).showIfNotDefault(null);
try {
cursor = context.getContentResolver().query(getUri(), MessageColumns.PROJECTION, null, null, SmsHelper.sortDateDesc);
cursor.moveToFirst();
MessageColumns.ColumnsMap columnsMap = new MessageColumns.ColumnsMap(cursor);
MessageItem message = new MessageItem(context, cursor.getString(columnsMap.mColumnMsgType), cursor, columnsMap, null, true);
if (message.isMe()) {
while (cursor.moveToNext()) {
MessageItem message2 = new MessageItem(context, cursor.getString(columnsMap.mColumnMsgType), cursor, columnsMap, null, true);
if (!message2.isMe()) {
message = message2;
break;
}
}
}
ContentValues cv = new ContentValues();
cv.put("read", false);
cv.put("seen", false);
context.getContentResolver().update(message.mMessageUri, cv, null, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
NotificationManager.create(context);
}
Aggregations