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.