You can use this code. It works perfect for me: // URI public static final String URI_INBOX = "content://sms"; public static final String URI_SENT = "content://sms/sent";
/** * Get all sms from database which have been sent after <code>time</ code> * @param time * @return */ public void getSms(long time) { Cursor c = mContext.getContentResolver().query(Uri.parse(URI_INBOX), null, Sms.DATE + " > '" + time + "'", null, null); if (c.moveToFirst()) { do{ String isIncomingType = ""; switch (Integer.parseInt(c.getString( c.getColumnIndex(Sms.TYPE)))) { case 1: isIncomingType = "YES";// Received break; case 2: isIncomingType = "NO";//"Outgoing"; break; case 3: isIncomingType = "NO";//"Missed"; } // number, name, date String number = c.getString(c.getColumnIndex(Sms.ADDRESS)); String name = c.getString(c.getColumnIndex(Sms.PERSON)); String body = c.getString(c.getColumnIndex(Sms.BODY)); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz"); String date = dateFormat.format(new Date(c.getInt(c.getColumnIndex(Sms.DATE)))); // etc etc etc } while (c.moveToNext()); } c.close(); } static class Sms { public static final String _ID = "_id"; public static final String THREAD_ID = "thread_id"; public static final String ADDRESS = "address"; public static final String PERSON = "person"; public static final String DATE = "date"; public static final String PROTOCOL = "protocol"; public static final String READ = "read"; public static final String STATUS = "status"; public static final String TYPE = "type"; public static final String REPLY_PATH_PRESENT = "reply_path_present"; public static final String SUBJECT = "subject"; public static final String BODY = "body"; public static final String SERVICE_CENTER = "service_center"; public static final String LOCKED = "locked"; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en