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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:53:33+00:00 2026-06-08T07:53:33+00:00

I am creating one android test application , in which i have one button.

  • 0

I am creating one android test application , in which i have one button. On button click ,i want to synchronize phonebook records with my local database.If record in phone book is not in db table then insert it , otherwise leave it as it is. so how can i do this?

  • 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-08T07:53:35+00:00Added an answer on June 8, 2026 at 7:53 am

    For getting contact list from your phone book you need write permission in AndroidManifest.XML (i.e. android.permission.READ_CONTACTS) .And you can collect contact list using following method.

              ShowContact()
             {
               ArrayList<String> nameList;
               ArrayList<String> phoneNoList;
    
               ContentResolver cr = getContentResolver();
               Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
                null, null, null, null);
               if (cur.getCount() > 0) {
              while (cur.moveToNext()) {
                String id = cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts._ID));
                String name = cur.getString(
                        cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                   if(Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                       //Query phone here.  Covered next
    
                     Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", 
                     new String[]{id}, null);
                      while (pCur.moveToNext()) {
                    // Do something with phones
                        String phoneNo = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
    
                        nameList.add(name); // Here you can list of contact.
                        phoneNoList.add(phoneNo); // And here you can get list of phone number.You have to query separately for getting phone_no,email,name etc 
       // Here you have to iterate this(i.e. nameList) with your list in the database.And your rest of logic.
    
                    } 
                    pCur.close();                 
            }
         }      
       }
    }
    

    And Let me know if are having any issue in getting contact list.

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

Sidebar

Related Questions

I am creating one application in which i am using jsp/servlet.. I want to
I'm am creating an Android application, but in order to have one of the
I have a question in Android during creating my google-maps application. I've one activity
I am creating one form in html using table. Which have one Drop down
I've creating one ASP web application, in that application one form have to update
I am creating one GUI in swing Java. I have to use one button
I'm creating one-click python installer (integrated with my application). Is there any way to
I am new to android. I was creating one sample page in which I
I'm writing my first Android application and I have one activity that I'd like
I'm creating one application in android to rotate an image using angle in html

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.