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 9201357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:59:14+00:00 2026-06-17T22:59:14+00:00

I am implementing a SMS App, till now i achieved to get all the

  • 0

I am implementing a SMS App, till now i achieved to get all the messages(sent, received, drafts) with its contact number, thread id, contact id, date, type.

Here is my code:

Uri mSmsinboxQueryUri = Uri.parse("content://sms");
        Cursor cursor = _context.getContentResolver().query(
                mSmsinboxQueryUri,
                new String[] { "_id", "thread_id", "address", "date", "body",
                        "type" }, null, null, null);

        String[] columns = new String[] { "address", "thread_id", "date",
                "body", "type" };
        if (cursor.getCount() > 0) {

            while (cursor.moveToNext()) {

                String address = null, date = null, msg = null, type = null, threadId = null;

                address = cursor.getString(cursor.getColumnIndex(columns[0]));
                threadId = cursor.getString(cursor.getColumnIndex(columns[1]));
                date = cursor.getString(cursor.getColumnIndex(columns[2]));
                msg = cursor.getString(cursor.getColumnIndex(columns[3]));
                type = cursor.getString(cursor.getColumnIndex(columns[4]));

                Log.e("SMS-inbox", "\nTHREAD_ID: "
                        + threadId + "\nNUMBER: " + address + "\nTIME: " + date + "\nMESSAGE: " + msg + "\nTYPE: " + type);
            }
        }
    }

Now, I need to separate these messages by thread id (messages with same thread id). How can I best achieve that? Thanks!

  • 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-17T22:59:15+00:00Added an answer on June 17, 2026 at 10:59 pm

    I would not save those strings seperatly in the first place.

    What I would do is a class like:

    public class SmsMsg {
        private String address = null;
        private String threadId = null;
        private String date = null;
        private String msg = null;
        private String type = null;
    
        //c'tor
        public SmsMsg(Cursor cursor) {
           this.address = cursor.getString(cursor.getColumnIndex("address"));
           this.threadId = cursor.getString(cursor.getColumnIndex("thread_id"));
           this.date = cursor.getString(cursor.getColumnIndex("date"));
           this.msg = cursor.getString(cursor.getColumnIndex("body"));
           this.type = cursor.getString(cursor.getColumnIndex("type")); 
        }
    }
    

    now you can instantiate an object of SmsMsg in your while-loop as long cursor.moveToNext() is true and add it to a List of your choice.

    You now could copy all messages of a desired threadId to a different List and sort it by date for example. That depends on what you want do do with it.

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

Sidebar

Related Questions

I implementing a EventQueue and get notified when AWTEvents are send. I wait till
I'm implementing a SMS verification system. this system is provided by a third party
Before implementing j_security_check using MySQL realm authentication in my web app. I had the
Implementing a Thread by providing a new class that extends Thread and overriding its
I am implementing an IM app on iOS. I found that three20 library has
I'm building an application implementing Bluetooth , Wifi , Phone call and Sms using
I have a rails application that I am implementing the Twilio SMS API on,
Implementing Ajax requests in my rails 3 app has been one of the most
I am getting this error while implementing SMS sending in android. Attaching the image
Implementing an app where the user can log in I have the following situation:

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.