Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:14:46+00:00 2026-06-07T05:14:46+00:00

I am using 2.1 platform.Trying to retrieve all the SMS from the Emulator. No

  • 0

I am using 2.1 platform.Trying to retrieve all the SMS from the Emulator. No Compile error, NO Logcat Error in my code.I included the permission for ReadSMS in manifest file.When I run the code no display in the ListView. In my XML file there is only one ListView. On that ListView I am trying to display all the SMS of format ( Number : Sms Body) from the Emulator.

Code

public class SMSActivity extends Activity {
/** Called when the activity is first created. */
    ListView lview;
    String Body  = "" ; 
    int Number;
    ArrayList<String> smslist=new ArrayList<String>();
    ArrayAdapter<String> itemAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main);
    lview =(ListView)findViewById(R.id.lv);
    itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,smslist);
    lview.setAdapter(itemAdapter);

    ContentResolver cr = getContentResolver();
    Cursor c = cr.query(Uri.parse("content://sms/"), new String[] { "_id", "address", "date", "body","read" },"_id = "+null, null, null);

    while(c.moveToNext()){

    Number = c.getInt(c.getColumnIndexOrThrow("address"));

   Body = c.getString(c.getColumnIndexOrThrow("body")).toString();

   smslist.add( Number + "\n" + Body);
    }
    itemAdapter.notifyDataSetChanged();
    c.close();
}
} 

How to solve this problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:14:50+00:00Added an answer on June 7, 2026 at 5:14 am

    The error you are doing is you just mentioning that you want to read sms but you forgot to say
    from which folder you need them.e.g from inbox,outbox etc..

    If you need to read SMS from inbox use following.

    Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
    

    You can also query column names using

    for (int i = 0; i < cursor.getColumnCount(); i++) {
    
        Log.i("info", cursor.getColumnName(i));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using gtk# on a cross platform application and trying to fix all the warnings,
I'm trying to develop a cross-platform application using C++ with boost. I typically program
I am currently building a small visual designer using the Netbeans Platform. All my
I am trying to develop a multi-screen app for the Google TV platform using
Our team is currently using some ported code from an old architecture to a
I am trying to upload pictures on the wall of Facebook using Android platform.
Platform: Shiro 1.1.0, Spring 3.0.5 I'm trying to secure the MVC Controller methods using
I'm trying to do some multi-monitor stuff using Platform Invoke. I've been using http://pinvoke.net
I am trying to install my own android application on SDcard using windows platform.
I am trying to customise an image for Windows CE6 using platform builder. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.