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

  • SEARCH
  • Home
  • 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 7511097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:26:49+00:00 2026-05-29T23:26:49+00:00

When I query the content://sms/ content provider and pull information from the address column;

  • 0

When I query the “content://sms/” content provider and pull information from the address column; I always get the phone number that the message is “from” or “sent to”. If I receive a message, then address is the number from the other person’s phone. When I send a message, then address is the message I am sending to.

How do I differentiate if a message in “content://sms/” folder is a sent message or received message without querying the respective inbox/sent folders?

    Uri uri = Uri.parse("content://sms/");
    String[] columns = new String[] { "_id", "thread_id", "address", "person", "date", "body" };
    String selection = "thread_id = " + threadId;
    String sortOrder = "date DESC";
    String limit = "LIMIT " + String.valueOf(mItemsOnPage);

    TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String deviceNumber = tm.getLine1Number();

    Cursor cursor = getContentResolver().query(uri, columns, selection, null,
            sortOrder + " " + limit);

    if (cursor != null) {
        cursor.moveToLast();

        while (!cursor.isBeforeFirst()) {
            long messageId = cursor.getLong(0);
            String address = cursor.getString(2);
            long date = cursor.getLong(4);
            String body = cursor.getString(5);
            long person = cursor.getLong(3);
            cursor.moveToPrevious();
        }
    }
    cursor.close();
  • 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-05-29T23:26:50+00:00Added an answer on May 29, 2026 at 11:26 pm

    You need to include the column type in your query. It contains a long indicating whether you are dealing with a received (type == 1) or sent (type == 2) message.

    This way you’ll know how to interpret the address column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a android application which read the sms from content provider.
I recently read that the content provider content://sms shouldn't be used to access the
String address = 0123456789; Cursor unreadcountcursor = getContentResolver().query(Uri.parse(content://sms/inbox), new String[]{}, read = 0 and
I have a content query web part that queries by content type against a
I am trying to setup a content query web part in MOSS that will
SQL query: SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date FROM ArticleCategories INNER JOIN Articles
I have a content observer that polls content://sms/ in android 1.5 so that I
I had a textarea, when i post that content in textarea, I only get
It seems that mysql select content (as opposed to e.g. count) queries always take
I want to get Details of SMS(Number, Text Body, Time of coming); And i

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.