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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:00:33+00:00 2026-05-27T23:00:33+00:00

I am a developing an application for composing sms in android platform. For that

  • 0

I am a developing an application for composing sms in android platform. For that i need to get “Contacts”, “Recent Contacts” and “Groups”. Please tell me any tutorial or the code of how to do it. When we click on any of these three buttons there should be contacts along with a checkbox for selecting multiple contacts.
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-05-27T23:00:33+00:00Added an answer on May 27, 2026 at 11:00 pm

    here is the code to get contacts programmatically

        ContentResolver cr = getContentResolver();
         Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
        null, null, null);
      String id = null, name = null, email = null, phone = null, note = null, orgName =     null, title = null;
      String Phone1 = "unknown", Phone2 = "unknown", Phone3 = "unknown", type1 = "unknown",        type2 = "unknown", type3 = "unknown";
      int size = cur.getCount();
    if (cur.getCount() > 0) {
        int cnt = 1;
        while (cur.moveToNext())
        {
            email = "";
            name = "";
            cnt++;
            id = cur.getString(cur
                    .getColumnIndex(ContactsContract.Contacts._ID));
            name = cur
                    .getString(cur
                            .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
    
            if (name != null && name != "") {
                if (!checkEmail(name)) {
                    email = "";
    
                } else {
                    email = name;
                    name = "";
                }
            }
            if (Integer
                    .parseInt(cur.getString(cur
                            .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0)
    
            {
                System.out.println("name : " + name);
                Cursor pCur = cr
                        .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                null,
                                ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                        + " = ?", new String[] { id },
                                null);
    
                Phone1 = " ";
                Phone2 = " ";
                Phone3 = " ";
                while (pCur.moveToNext())
                {
                    String phonetype = pCur
                            .getString(pCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
                    String MainNumber = pCur
                            .getString(pCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                    if (phonetype.equalsIgnoreCase("1")) {
                        Phone1 = MainNumber;
                        type1 = "home";
                    } else if (phonetype.equalsIgnoreCase("2")) {
                        Phone2 = MainNumber;
                        type2 = "mobile";
                    } else {
                        Phone3 = MainNumber;
                        type3 = "work";
                    }
                }
                pCur.close();
    
            }
                Cursor addrCur = cr
                        .query(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI,
                                null,
                                ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID
                                        + " = ?", new String[] { id },
                                null);
                if (addrCur.getCount() == 0) {
                    addbuffer.append("unknown");
                } else {
                    int cntr = 0;
                    while (addrCur.moveToNext()) {
    
                        cntr++;
                        String poBox = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POBOX));
                        if (poBox == null) {
                            poBox = " ";
                        }
                        String street = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.STREET));
                        if (street == null) {
                            street = " ";
                        }
                        String neb = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.NEIGHBORHOOD));
                        if (neb == null) {
                            neb = " ";
                        }
                        String city = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CITY));
                        if (city == null) {
                            city = " ";
                        }
                        String state = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.REGION));
                        if (state == null) {
                            state = " ";
                        }
                        String postalCode = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE));
                        if (postalCode == null) {
                            postalCode = " ";
                        }
                        String country = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY));
                        if (country == null) {
                            country = " ";
                        }
    
                        String type = addrCur
                                .getString(addrCur
                                        .getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.TYPE));
                        if (type == null) {
                            type = " ";
                        }
                    }
    
                }
    
                addrCur.close();
    
                String noteWhere = ContactsContract.Data.CONTACT_ID
                        + " = ? AND " + ContactsContract.Data.MIMETYPE
                        + " = ?";
                String[] noteWhereParams = new String[] {
                        id,
                        ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE };
                Cursor noteCur = cr.query(
                        ContactsContract.Data.CONTENT_URI, null,
                        noteWhere, noteWhereParams, null);
    
                note = " ";
    
                if (noteCur.moveToFirst()) {
                    note = noteCur
                            .getString(noteCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Note.NOTE));
    
                    if (note == null) {
                        note = " ";
                    }
                }
                noteCur.close();
                String orgWhere = ContactsContract.Data.CONTACT_ID
                        + " = ? AND " + ContactsContract.Data.MIMETYPE
                        + " = ?";
                String[] orgWhereParams = new String[] {
                        id,
                        ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE };
                Cursor orgCur = cr.query(
                        ContactsContract.Data.CONTENT_URI, null,
                        orgWhere, orgWhereParams, null);
                orgName = " ";
                if (orgCur.moveToFirst()) {
                    orgName = orgCur
                            .getString(orgCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Organization.COMPANY));
    
                }
                if (orgName == null) {
                    orgName = " ";
                }
                orgCur.close();
    
                Cursor emailCur = cr
                        .query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
                                null,
                                ContactsContract.CommonDataKinds.Email.CONTACT_ID
                                        + " = ?", new String[] { id },
                                null);
                email = "unknown";
                while (emailCur.moveToNext()) {
    
                    email = emailCur
                            .getString(emailCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
                    String emailType = emailCur
                            .getString(emailCur
                                    .getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
    
                    if (email == null) {
                        email = "unknown";
                    }
                    if (emailType.equalsIgnoreCase("1")) {
                    } else {
                    }
                }
    
                // add
                emailCur.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing application in N-Tier Architecture. as we all know that we need
I'm developing an Android application that makes a Query using Activity.managedQuery() , which takes
I am developing application where i need to get users phone number. Now i
I'm developing application with GWT 2 and would like to add float panel that
When developing an application that sends out notification email messages, what are the best
I am developing an application simulating a network comprising a number of nodes that
I'm developing an Android application. I have a database table and I want to
I am developing a web application where I need to find the closest bus-stop
At work, we are developing an PHP application that would be later re-programmed into
I am developing an application which need to handle a massive amount of REST

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.