List of usage examples for android.database.sqlite SqliteWrapper query
@UnsupportedAppUsage public static Cursor query(Context context, ContentResolver resolver, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
From source file:com.android.mms.transaction.MessagingNotification.java
private static int getUndeliveredMessageCount(Context context) { Cursor undeliveredCursor = SqliteWrapper.query(context, context.getContentResolver(), UNDELIVERED_URI, MMS_THREAD_ID_PROJECTION, "read=0", null, null); if (undeliveredCursor == null) { return 0; }//ww w . ja va 2s . c o m int count = undeliveredCursor.getCount(); undeliveredCursor.close(); return count; }
From source file:com.android.mms.transaction.MessagingNotification.java
/** * If all the undelivered messages belong to "threadId", cancel the notification. */// ww w. ja v a2 s. c o m public static void updateSendFailedNotificationForThread(Context context, long threadId) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), UNDELIVERED_URI, MMS_THREAD_ID_PROJECTION, "read=0", null, null); if (cursor == null) { return; } try { if (cursor.getCount() > 0 && getUndeliveredMessageThreadId(cursor) == threadId && isFailedMessagesInSameThread(cursor)) { cancelNotification(context, MESSAGE_FAILED_NOTIFICATION_ID); } } finally { cursor.close(); } }
From source file:com.android.mms.transaction.MessagingNotification.java
private static int getDownloadFailedMessageCount(Context context) { // Look for any messages in the MMS Inbox that are of the type // NOTIFICATION_IND (i.e. not already downloaded) and in the // permanent failure state. If there are none, cancel any // failed download notification. Cursor c = SqliteWrapper .query(context, context.getContentResolver(), Mms.Inbox.CONTENT_URI, null, Mms.MESSAGE_TYPE + "=" + String.valueOf(PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) + " AND " + Mms.STATUS + "=" + String.valueOf(DownloadManager.STATE_PERMANENT_FAILURE), null, null);// w ww . j av a 2 s.com if (c == null) { return 0; } int count = c.getCount(); c.close(); return count; }
From source file:com.android.mms.transaction.MessagingNotification.java
/** * Get the thread ID of the SMS message with the given URI * @param context The context//from w ww .j a va 2s . c o m * @param uri The URI of the SMS message * @return The thread ID, or THREAD_NONE if the URI contains no entries */ public static long getSmsThreadId(Context context, Uri uri) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), uri, SMS_THREAD_ID_PROJECTION, null, null, null); if (cursor == null) { if (DEBUG) { Log.d(TAG, "getSmsThreadId uri: " + uri + " NULL cursor! returning THREAD_NONE"); } return THREAD_NONE; } try { if (cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(Sms.THREAD_ID); if (columnIndex < 0) { if (DEBUG) { Log.d(TAG, "getSmsThreadId uri: " + uri + " Couldn't read row 0, col -1! returning THREAD_NONE"); } return THREAD_NONE; } long threadId = cursor.getLong(columnIndex); if (DEBUG) { Log.d(TAG, "getSmsThreadId uri: " + uri + " returning threadId: " + threadId); } return threadId; } else { if (DEBUG) { Log.d(TAG, "getSmsThreadId uri: " + uri + " NULL cursor! returning THREAD_NONE"); } return THREAD_NONE; } } finally { cursor.close(); } }
From source file:com.android.mms.transaction.MessagingNotification.java
/** * Get the thread ID of the MMS message with the given URI * @param context The context// w w w .j a va2 s .c om * @param uri The URI of the SMS message * @return The thread ID, or THREAD_NONE if the URI contains no entries */ public static long getThreadId(Context context, Uri uri) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), uri, MMS_THREAD_ID_PROJECTION, null, null, null); if (cursor == null) { if (DEBUG) { Log.d(TAG, "getThreadId uri: " + uri + " NULL cursor! returning THREAD_NONE"); } return THREAD_NONE; } try { if (cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(Mms.THREAD_ID); if (columnIndex < 0) { if (DEBUG) { Log.d(TAG, "getThreadId uri: " + uri + " Couldn't read row 0, col -1! returning THREAD_NONE"); } return THREAD_NONE; } long threadId = cursor.getLong(columnIndex); if (DEBUG) { Log.d(TAG, "getThreadId uri: " + uri + " returning threadId: " + threadId); } return threadId; } else { if (DEBUG) { Log.d(TAG, "getThreadId uri: " + uri + " NULL cursor! returning THREAD_NONE"); } return THREAD_NONE; } } finally { cursor.close(); } }
From source file:com.android.mms.ui.MessageUtils.java
private static int getUnreadMessageNumber(Context context) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Uri.parse("content://mms-sms/unread_count"), null, null, null, null); if (cursor != null) { try {/* www . ja v a2s .c om*/ if (cursor.moveToFirst()) { int count = cursor.getInt(0); MmsLog.d(MmsApp.TXN_TAG, "unread message count: " + count); return count; } } finally { cursor.close(); } } else { MmsLog.d(MmsApp.TXN_TAG, "can not get unread message count."); } return 0; }
From source file:com.android.mms.ui.MessageUtils.java
public static List<MmsReportStatus> getMmsReportStatus(Context context, long messageId) { MmsLog.d(TAG, "getMmsReportStatus(): messageId = " + messageId); Uri uri = Uri.withAppendedPath(Mms.REPORT_STATUS_URI, String.valueOf(messageId)); Cursor c = SqliteWrapper.query(context, context.getContentResolver(), uri, new String[] { Mms.Addr.ADDRESS, "delivery_status", "read_status" }, null, null, null); if (c == null) { return null; }/*w ww.j av a 2 s . c o m*/ try { List<MmsReportStatus> mmsReportStatusList = new ArrayList<MmsReportStatus>(); while (c.moveToNext()) { int columnDeliveryStatus = 1; int columnReadStatus = 2; mmsReportStatusList .add(new MmsReportStatus(c.getInt(columnDeliveryStatus), c.getInt(columnReadStatus))); } return mmsReportStatusList; } finally { c.close(); } }
From source file:com.android.mms.ui.MessageUtils.java
public static boolean haveEmailContact(String emailAddress, Context context) { Cursor cursor = SqliteWrapper.query(context, context.getContentResolver(), Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(emailAddress)), new String[] { Contacts.DISPLAY_NAME }, null, null, null); if (cursor != null) { try {//w w w .j ava 2 s . c om String name; while (cursor.moveToNext()) { name = cursor.getString(0); if (!TextUtils.isEmpty(name)) { return true; } } } finally { cursor.close(); } } return false; }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private long getMessageDate(Uri uri) { if (uri != null) { Cursor cursor = SqliteWrapper.query(this, mContentResolver, uri, new String[] { Mms.DATE }, null, null, null);// w ww . j a va2 s .c om if (cursor != null) { try { if ((cursor.getCount() == 1) && cursor.moveToFirst()) { return cursor.getLong(0) * 1000L; } } finally { cursor.close(); } } } return NO_DATE_FOR_DIALOG; }