How to access the messages in inbox

Tutorials with advanced 'difficulty' and more Lines of Code.

How to access the messages in inbox

Postby streetfi8er » Sun Jun 13, 2010 3:14 pm

Can someone please give a tutorial on how to access the messages in the inbox programmatically?
streetfi8er
Junior Developer
Junior Developer
 
Posts: 15
Joined: Sat Jun 12, 2010 1:03 am

Top

Re: How to access the messages in inbox

Postby st0le » Fri Jun 18, 2010 6:16 am

Code: Select all
   public final static String SMS_URI_ALL =  "content://sms/"; //0
   public final static String SMS_URI_INBOX = "content://sms/inbox";//1
   public final static String SMS_URI_SENT = "content://sms/sent";//2
   public final static String SMS_URI_DRAFT = "content://sms/draft";//3
   public final static String SMS_URI_OUTBOX = "content://sms/outbox";//4
   public final static String SMS_URI_FAILED = "content://sms/failed";//5
   public final static String SMS_URI_QUEUED = "content://sms/queued";//6


   //inbox structure
   //   _id =>  Short message sequence number such as  100
   //   thread_id =>  The ordinal as a dialogue  100
   //   address =>  The sender address, cell phone number  . If  +8613811810000
   //   person =>  The sender, returns a number is an ordinal number in your contacts list  , Strangers to  null
   //   date =>  Date long  . If  1256539465022
   //   protocol =>  Protocol   0 SMS_RPOTO, 1 MMS_PROTO
   //   read =>  Whether reading 0 unread  , 1 Read 
   //   status =>  Receive State-1  ,0 complete, 64 pending, 128 failed
   //   type =>  Type 1 is received  ,2 Is issued 
   //   body =>  Short message content 
   //   service_center =>  Short message service center number number.  +8613800755500
   static final String SMSATTRIBUTES_ID = "_id";
   static final String SMSATTRIBUTES_THREADID = "thread_id";
   static final String SMSATTRIBUTES_SENDERNO = "address";
   static final String SMSATTRIBUTES_PERSON = "person";
   static final String SMSATTRIBUTES_DATE = "date";
   static final String SMSATTRIBUTES_PROTOCOL = "protocol";
   static final String SMSATTRIBUTES_READ = "read";
   static final String SMSATTRIBUTES_STATUS = "status";
   static final String SMSATTRIBUTES_TYPE = "type";
   static final String SMSATTRIBUTES_BODY = "body";
   static final String SMSATTRIBUTES_SERVICECENTER = "service_center";
   static final String SMSATTRIBUTES_REPLY = "reply_path_present";
   static final String SMSATTRIBUTES_LOCKED = "locked";
   static final String SMSATTRIBUTES_SUBJECT = "subject";

   static final int SMSATTRIBUTES_INDEX_ID = 0;
   static final int SMSATTRIBUTES_INDEX_THREADID = 1;
   static final int SMSATTRIBUTES_INDEX_ADDRESS = 2;
   static final int SMSATTRIBUTES_INDEX_PERSON = 3;
   static final int SMSATTRIBUTES_INDEX_DATE = 4;
   static final int SMSATTRIBUTES_INDEX_PROTOCOL = 5;
   static final int SMSATTRIBUTES_INDEX_READ = 6;
   static final int SMSATTRIBUTES_INDEX_STATUS = 7;
   static final int SMSATTRIBUTES_INDEX_TYPE = 8;
   static final int SMSATTRIBUTES_INDEX_REPLY = 9;
   static final int SMSATTRIBUTES_INDEX_SUBJECT = 10;
   static final int SMSATTRIBUTES_INDEX_BODY = 11;
   static final int SMSATTRIBUTES_INDEX_SERVICECENTER = 12;
   static final int SMSATTRIBUTES_INDEX_LOCKED = 13;

you'll get a cursor to our inbox using
Cursor c = context.getContentResolver().query(Uri.parse(SMS_URI_INBOX), null, null, null, SMSATTRIBUTES_ID + " desc");
//sorted according to message arrival.


This should help...
st0le
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Jun 18, 2010 5:59 am

Re: How to access the messages in inbox

Postby streetfi8er » Fri Jun 25, 2010 3:42 pm

thanks a lot :)
streetfi8er
Junior Developer
Junior Developer
 
Posts: 15
Joined: Sat Jun 12, 2010 1:03 am

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests