1
ContentResolver cr = this.getContentResolver();
Cursor cursor = cr.query(Uri.parse("content://sms/inbox"), null, null,null, null);
cursor.moveToFirst();

if (cursor.getCount() > 0) {
    for (int j = 0; j < cursor.getCount(); j++) {
        String text = cursor.getString(
        cursor.getColumnIndexOrThrow("body")).toString();
        Log.d("sms", text);
        cursor.moveToNext();
    }
} else
    Log.d("no", "not working");
}

I also givev permission <uses-permission android:name="android.permission.READ_SMS"/> in androidmanifest.xml file it shows no notworking

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
Nalini Wanjale
  • 1,717
  • 4
  • 19
  • 24
  • 1
    possible duplicate of [How can I read SMS messages from the inbox programmatically in Android?](http://stackoverflow.com/questions/848728/how-can-i-read-sms-messages-from-the-inbox-programmatically-in-android) – JoxTraex Sep 08 '12 at 06:58
  • Could you please explain what you mean by "not working" ? What problems are you facing ? – Swayam Sep 08 '12 at 08:23
  • .. and have you confirmed there are SMS messages in the inbox? (by default, there won't be anything in the emulator) – Sameer Sep 08 '12 at 08:27
  • @swayam-just to know wheather it is gong in if or else – Nalini Wanjale Sep 08 '12 at 15:11
  • @sameer-yes i insert 2 sms to emulator – Nalini Wanjale Sep 08 '12 at 15:13
  • Hey it works:-)i guess this code was nt working coz inbox of emulator contain sms send by itself..when i send sms using another emulator it works...by the way thanks to all f u – Nalini Wanjale Sep 08 '12 at 15:23

0 Answers0