Back to project page firstcodeandroid.
The source code is released under:
MIT License
If you think the Android project firstcodeandroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jikexueyuan.getmyphonenumber; //from w w w.j ava2s . c om import java.util.ArrayList; import java.util.List; import android.content.Context; import android.database.Cursor; import android.provider.ContactsContract.CommonDataKinds.Phone; public class GetNumber { public static List<PhoneInfo> lists = new ArrayList<PhoneInfo>(); public static String getNumber(Context context){ Cursor cursor = context.getContentResolver().query(Phone.CONTENT_URI, null, null, null, null); String phoneNumber; String phoneName; while (cursor.moveToNext()) { phoneNumber = cursor.getString(cursor.getColumnIndex(Phone.NUMBER)); phoneName = cursor.getString(cursor.getColumnIndex(Phone.DISPLAY_NAME)); PhoneInfo phoneInfo = new PhoneInfo(phoneName, phoneNumber); lists.add(phoneInfo); System.out.println(phoneName+phoneNumber); } return null; } }