Android Reading Inbox SMS

Sample source code for reading inbox sms

import android.database.Cursor;
import android.os.Bundle;
import android.widget.TextView;

public class SMSRead extends Activity {

public void onCreate(Bundle savedInstanceState) {
TextView view = new TextView(this);
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
String sms = "";
while (cur.moveToNext()) {
sms += "From :" + cur.getString(2) + " : " + cur.getString(11)+"\n";

Add below permission to AndroidManifest.xml

<uses-permission name="android.permission.READ_SMS" />


  1. Hi
    Nice tutorial save my time .But i have one question how we read the new incoming message.I want to read the new incoming messages any idea about this

    1. Make BroadCast Receiver for incoming message.

  2. Hi
    Please tell me how to view the new incoming message in android

  3. Setup the Android Manifest with the permission and the Intent Receiver

    Code a simple Intent Listener
    package org.apache.sms;

    import android.content.Context;
    import android.content.Intent;
    import android.content.IntentReceiver;
    import android.os.Bundle;
    import android.provider.Telephony;
    import android.util.Log;
    import android.telephony.gsm.SmsMessage;

    public class SMSApp extends IntentReceiver {
    private static final String LOG_TAG = "SMSApp";

    /* package */ static final String ACTION =

    public void onReceiveIntent(Context context, Intent intent) {
    if (intent.getAction().equals(ACTION)) {
    StringBuilder buf = new StringBuilder();
    Bundle bundle = intent.getExtras();
    if (bundle != null) {
    SmsMessage[] messages = Telephony.Sms.Intents.getMessagesFromIntent(intent);
    for (int i = 0; i < messages.length; i++) {
    SmsMessage message = messages[i];
    buf.append("Received SMS from ");
    buf.append(" - ");
    Log.i(LOG_TAG, "[SMSApp] onReceiveIntent: " + buf);
    NotificationManager nm = (NotificationManager) context.getSystemService(

    nm.notifyWithText(123, buf.toString(),
    NotificationManager.LENGTH_LONG, null);


    private void appendData(StringBuilder buf, String key, String value) {
    buf.append(", ");

  4. can u please tell us how to run this code in sdk at our desktop please?

  5. wonder & great . I really thankful to you

  6. uses-permission has a printing mistake. it should be like this:

  7. help me!
    i want hide display when my phone reciever incoming to do it ? please.

  8. i want detail code to block sms using the keyword given in textbox and to block sms from selected number in contact list...anybody help plz..

  9. hi everybody
    i am working my project.When have an incoming phone call, the screen has not changed its.How to do it (can somebody give me a little code for this problem ) ? please help me!

  10. Appication force quits as i run

  11. It's work perfectly
    Thank you for sharing ;)
    Android The Best!

  12. please tell me code to read data from mmssms.db

  13. i need some help
    i am making a projrect in which i received the GPS coordinates througth sms into the google andriod phone .
    my problem is i want to put the the coordinates from inbox of the andriod phone in to the google map through some application.
    Means the app should continuously get the coordinates from inbox and insert the coordinates for real time tracking plzzzzzz plzzzzzzzzzz plzzzzzzzzzzz any one help me out

  14. i need some help
    i am making a projrect in which i received the GPS coordinates througth sms into the google andriod phone .
    my problem is i want to put the the coordinates from inbox of the andriod phone in to the google map through some application.
    Means the app should continuously get the coordinates from inbox and insert the coordinates for real time tracking plzzzzzz plzzzzzzzzzz plzzzzzzzzzzz any one help me out
    plz mail me at

  15. Hi i need some help .
    In my application when i get new inbox message with content please call/help automatically read the incoming message phone number and show an alert with message content for ready to coll to that number or not.please help me

  16. please tell me how can I run this code in android sdk...?

  17. Nice Thread Tutorial, i am new in android , its help me a lot ...

    I have got some good links

    Incomming SMS Broadcast Receiver

  18. i am working on robotic,few dificulties i have found in by robot, it is working on android app,please help me in developing application for "sms reading and sending "

  19. your code is a gr8 gr8 gr8 help for me... i need little more help that if i want time stamp of each msg received how i can attain that????

  20. I am getting below error can u plz help me how can i reslove this below error

    java.lang.SecurityException: Neither user 10045 nor current process has android.permission.MODIFY_PHONE_STATE.

  21. it shows error "android.database.Cursor
    Note: This element has no attached Javadoc and the Javadoc could not be found in the attached source." how to fix it

  22. this code is not working for htc phone...

  23. Hello All,

    I want to make a project in android like reading the message from the inbox and display full message into once it is clicked on particular message. I have used the listview to display the message but it is display the entire content on listview but i want it to display the full msg one it is clicked on particular msg not all at the same time.Like how we are using the mobile inbox msg to read the msg. Please do help if you know.

    Thank you..

  24. can any one give me a code for the restore sms backup...???
    thanx in advance

  25. Hi,
    I want to get body of SMS when I click on one. I have tried an approach simmilar to contact picker. Here is my code :

    public class Decrypt extends Fragment {
    Button loadButton;
    EditText smsDisplay;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    View v = inflater.inflate(R.layout.decrypt, null);
    // Button loadButton=(Button)v.findViewById(
    loadButton.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {

    Intent sendIntent = new Intent(Intent.ACTION_VIEW);


    return v;


    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // if (resultCode == Activity.RESULT_OK) {
    Uri ur = data.getData();
    Cursor c = getActivity().getContentResolver().query(ur, null, null,
    null, null);
    if (c.moveToFirst()) {
    String s = c
    Toast.makeText(getActivity(), s, Toast.LENGTH_LONG).show();
    }catch(Exception e){
    // }

    It opens a Inbox like when I open original sms app in anroid, but when I click on one message it doesnt copy body of that sms in my edittext. Please couul you look at my code and find mistake?

    Thanks a lot for your time

  26. Hi friends;

    I want to make a app like whatsapp plz help . all data let say communication , messaging , status


  27. Hi

    using this code i'm getting messages are displaying with mobile numbers instead of names stored for number's in contact book. Can anyone help me with that ?

  28. Wow, finally i got good code, it was worked well, i had searching many sites about this code, Thanks for sharing, keep updating

    Android app development company

  29. how to delete sms from sim card in android

  30. hello everyone.i have required source code of simple sms & contacts backup for my project.if anyone have plz share on

  31. This comment has been removed by the author.

  32. hi I know to send sms from one emulator to second in android but i want to know how to send sms from the 2nd emulator from the 1st because as i press the "send" button the message is sent from 1st to 2nd and i can it as well but i cant give reply from 2nd to 1st emulator.Please help me to do that.

  33. Hi,it was a nice program.but i need the logic for to read sms from a particular number.please help.

  34. Hi,can someone help me creating a sms having a data aging and delete after certain period of time in android?

  35. This comment has been removed by the author.

  36. HAI,
    can you tell me code for how to create an app which reads my phone sms(not whatsapp or facebook message normal sms like company message or verification messages).
    which means when i am receiving a new sms it shows in that app

  37. Hey great article I will try using your code. Presently I am using SMS platform API code which is really great and robust in nature would suggest you also to check it out

  38. Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.Android Training in velachery | Android Training in chennai | Android Training in chennai with placement

  39. Hi at first thanks a lot for your tutorial! I need it for my app but I need also to get text from sms to editText when I click on one of those shown sms in list. Could you help me with this task or just give a hint ? Thanks for your time..Android Training in chennai | Best Android Training in chennai|Android Training in chennai with placement | Android Training in velachery

  40. Texting spy app allows you to track android's sms remotely. Learn more here.

  41. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Digital Mobile Marketing
    SMS Marketing

  42. This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Mobile Marketing Service
    Mobile Marketing Companies
    Texting API
    Sms API
    Sms marketing

  43. But am trouble with runtime permission for reading inbox sms pl help me to solve my problem