Android programming based on contacts read contacts (with demo source code) _android

Source: Internet
Author: User
Tags sqlite

This article illustrates the way Android programming reads contacts based on contacts. Share to everyone for your reference, specific as follows:

Introduction to Android Contacts:

Here is an introduction to the Android Address Book database. This includes the basics of Android using contacts to access SQLite and learn more about Android SQLite and contacts. Google has changed the contacts database from version 1 to version 2. Here is a brief introduction.

Contacts Read code:

Package com.homer.phone; 
Import java.util.ArrayList; 
Import Java.util.HashMap; 
Import android.app.Activity; 
Import Android.database.Cursor; 
Import Android.os.Bundle; 
Import Android.provider.ContactsContract; 
Import Android.provider.ContactsContract.CommonDataKinds.Phone; 
Import Android.widget.ListView; 
Import Android.widget.SimpleAdapter; public class Phoneread extends activity {@Override public void onCreate (Bundle savedinstancestate) {super.oncreate 
  (savedinstancestate); 
 Showlistview (); 
  private void Showlistview () {ListView ListView = new ListView (this); 
  arraylist 

Androidmanifest.xml Permissions

Remember to join Android.permission.READ_CONTACTS this permission in Androidmanifest.xml.

Copy Code code as follows:
<uses-permission android:name= "Android.permission.READ_CONTACTS"/>

Run Result:

Sample code Click here to download the site.

I hope this article will help you with the Android program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.