I had many query and it was taking lot of time to fetch contact data.
So need to convert all query in into one.
I got all other info like display name, mobile number, label, email in one query
but finding prob only with getting pics
Help me to Convert below photo query into single query and get uri of pics :
ContentResolver KntRslverVar = getContentResolver();
Cursor ContctKsrVar = KntRslverVar.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER},
null, null, null);
while (ContctKsrVar.moveToNext())
{
String ContctUidVar = ContctKsrVar.getString(ContctKsrVar.getColumnIndex(ContactsContract.Contacts._ID));
String ContctNamVar = ContctKsrVar.getString(ContctKsrVar.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String ContctMobVar = ContctKsrVar.getString(ContctKsrVar.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
Cursor ContctPflPicKsrVar = KntRslverVar.query(
ContactsContract.Data.CONTENT_URI,
null,
ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?",
new String[]{ContctUidVar, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE},
null);
if (ContctPflPicKsrVar != null && ContctPflPicKsrVar.getCount() > 0)
{
while(ContctPflPicKsrVar.moveToNext())
{
Uri ContctPflPicUriVar = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(ContctUidVar));
PflPicUriVar = Uri.withAppendedPath(ContctPflPicUriVar, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
}
ContctPflPicKsrVar.close();
}
}
Try 1 :
Cursor ContctKsrVar = KntRslverVar.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE},
null, null, null);
Try 2 :
Cursor ContctKsrVar = KntRslverVar.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER
ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI},
null, null, null);
Also need help on getting uri from fetched query :
Uri KctPflPicUriVar = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.parseLong(KctUidVar));
PflPicUriVar = Uri.withAppendedPath(KctPflPicUriVar, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
|*| Optimised : Get Display Name and Number with label and Photo Thumbnail in one query : Gets result query in less than 4 sec.
ContentResolver contntRslverVar = getContentResolver();
Cursor contctKsrVar = contntRslverVar.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone._ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.LABEL,
ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI},
null, null, null);
while (contctKsrVar.moveToNext())
{
String contctUidVar = contctKsrVar.getString(contctKsrVar.getColumnIndex(ContactsContract.Contacts._ID));
String contctNamVar = contctKsrVar.getString(contctKsrVar.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String contctMobVar = contctKsrVar.getString(contctKsrVar.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
int MobLblTypVar = contctKsrVar.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
int MobLblTipVar = contctKsrVar.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
MobLblTypVar = contctKsrVar.getInt(MobLblTypVar);
String contctMobLblVar;
if(MobLblTypVar == ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM)
{
contctMobLblVar = contctKsrVar.getString(MobLblTipVar);
}
else
{
CharSequence MobLblSrgVar = ContactsContract.CommonDataKinds.Phone.getTypeLabel(getResources(), MobLblTypVar, "Mobile");
contctMobLblVar = MobLblSrgVar.toString();
}
String PflPicSrgVar = contctKsrVar.getString(contctKsrVar.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI));
if(PflPicSrgVar != null) Uri PflPicUriVar = Uri.parse(PflPicSrgVar);
}
Related
In my application I try to search a contact using the phonenumber. The phonenumber I am searching with is always in the same format ('123456789' for example).
But the following code retrieves not all contacts I expected.
The main issue might be the different format of phonenumbers in my phone: some contacts are saved with '+12 345 6789', the other with '0123 456789'.
Although I tried ContactsContract.PhoneLookup.NORMALIZED_NUMBER my code retrieves only the contacts saved with phonenumbers in the '123456789'-format.
private String getContactDetails(Context context, String number) {
String[] projection = new String[] {
ContactsContract.PhoneLookup.DISPLAY_NAME,
ContactsContract.PhoneLookup._ID,
ContactsContract.PhoneLookup.LOOKUP_KEY};
int len = number.length();
Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number.substring(len-7)));
String selection = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
selection = ContactsContract.PhoneLookup.NORMALIZED_NUMBER + " LIKE %" + number.substring(len-7) + "%";
}
Cursor cursor = context.getContentResolver().query(contactUri, projection, selection, null, null);
String name = null;
if(cursor != null) {
if (cursor.moveToFirst()) {
name = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
}
cursor.close();
}
return name;
}
Don't use both PhoneLookup.CONTENT_FILTER_URI with selection, CONTENT_FILTER_URIs are used to search for data using the URI itself, and should not get any selection.
The PhoneLookup.NORMALIZED_NUMBER column is for getting the result back in an e164 format, not for querying.
Try this:
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode("123456789"));
String[] projection = new String[] { PhoneLookup.NUMBER, PhoneLookup.NORMALIZED_NUMBER };
Cursor c = getContentResolver().query(uri, projection, null, null, null);
if (c != null) {
if (c.moveToFirst()) {
String number = c.getString(0);
String e164_number = c.getString(1);
Log.d(TAG, "number=" + number + ", e164=" + e164_number);
} else {
Log.d(TAG, "couldn't find number");
}
}
c.close();
folks!
Look I broke my mind with problem -
how get display_name from ContactContract via _ID I got earlier???
Here is the code:
public static long getId(Context context, String number) {
long id = 0;
String displayName;
// define the columns I want the query to return
final String[] projection = new String[] {
ContactsContract.PhoneLookup.DISPLAY_NAME,
ContactsContract.PhoneLookup._ID};
// encode the phone number and build the filter URI
final Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
// query time
final Cursor cursor = context.getContentResolver().query(contactUri, projection, null, null, null);
if(cursor != null) {
if (cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
// HERE IS GOOD _ID!
id = cursor.getLong(cursor.getColumnIndex(ContactsContract.PhoneLookup._ID));
Log.d("_TAG_", displayName);
{
//
// v. N-1
//
Cursor cursor2 = context.getContentResolver().query(
contactUri,
projection,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
new String[]{String.valueOf(id)}, null);
if(cursor2 != null) {
// Cursor valid but string below got error "android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 1 : )"
displayName = cursor2.getString(cursor.getColumnIndex(ContactsContract.PhoneLookup.DISPLAY_NAME));
Log.d("_TAG_", displayName);
}
}
{
//
// v. N
//
Uri myPhoneUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(String.valueOf(id)));
Cursor phoneCursor = context.getContentResolver().query(
myPhoneUri, null, null, null, null);
for (phoneCursor.moveToFirst(); !phoneCursor.isAfterLast(); phoneCursor.moveToNext()) {
// No steps inside!
String str = phoneCursor.getString(phoneCursor
.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Nickname.NAME));
Log.d(App.LOG_TAG, "ContactUtils.getId: " + str);
}
if(phoneCursor != null) {
phoneCursor.close();
}
}
} else {
Log.d("_TAG_", "Contact Not Found # " + number);
}
cursor.close();
}
return id;
}
"v.N-1" and "v.N" are just 2 ones from a million attempts before.
See - I got _ID, so why it doesn't work back as valid query???
Here is decision i found.
public static String getDisplayName(Context context, long id) {
String displayName = null;
// define the columns I want the query to return
final String[] projection = new String[] {
ContactsContract.Contacts.DISPLAY_NAME,
};
final Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id + "" }, null);
if(cursor != null) {
if (cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
}
cursor.close();
}
return displayName;
}
It works...
For a given number from my address book, I need to look-up if the number has whatsapp enabled.
(The idea is to choose SMS/WhatsApp for initiating a text intent)
Lets say, I have two numbers under a contact, And I need to know which one has whatsapp enabled.
The "People" app on the Nexus 4 shows both contact numbers,
And also a little below has a CONNECTIONS section, which shows only the WhatsApp possible contact.
Is there a way to look up(like how People app does) ?
If you want to know if this contact has WhatsApp:
String[] projection = new String[] { RawContacts._ID };
String selection = ContactsContract.Data.CONTACT_ID + " = ? AND account_type IN (?)";
String[] selectionArgs = new String[] { "THE_CONTACT_DEVICE_ID", "com.whatsapp" };
Cursor cursor = activity.getContentResolver().query(RawContacts.CONTENT_URI, projection, selection, selectionArgs, null);
boolean hasWhatsApp = cursor.moveToNext();
if (hasWhatsApp){
String rowContactId = cursor.getString(0);
}
And to find to which number of this contact has WhatsApp
projection = new String[] { ContactsContract.Data.DATA3 };
selection = ContactsContract.Data.MIMETYPE + " = ? AND " + ContactsContract.Data.RAW_CONTACT_ID + " = ? ";
selectionArgs = new String[] { "vnd.android.cursor.item/vnd.com.whatsapp.profile", rawContactId };
cursor = CallAppApplication.get().getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, selection, selectionArgs, "1 LIMIT 1");
String phoneNumber = null;
if (cursor.moveToNext()) {
phoneNumber = cursor.getString(0);
}
Using #idog's method, I improved code to work easier. contactID is a string variable to be passed. If contact hasn't WhatsApp returns null, otherwise returns with contactID which has been passed as variable.
public String hasWhatsapp(String contactID) {
String rowContactId = null;
boolean hasWhatsApp;
String[] projection = new String[]{ContactsContract.RawContacts._ID};
String selection = ContactsContract.Data.CONTACT_ID + " = ? AND account_type IN (?)";
String[] selectionArgs = new String[]{contactID, "com.whatsapp"};
Cursor cursor = getActivity().getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, projection, selection, selectionArgs, null);
if (cursor != null) {
hasWhatsApp = cursor.moveToNext();
if (hasWhatsApp) {
rowContactId = cursor.getString(0);
}
cursor.close();
}
return rowContactId;
}
public int hasWhatsApp(String contactID) {
int whatsAppExists = 0;
boolean hasWhatsApp;
String[] projection = new String[]{ContactsContract.RawContacts._ID};
String selection = ContactsContract.Data.CONTACT_ID + " = ? AND account_type IN (?)";
String[] selectionArgs = new String[]{contactID, "com.whatsapp"};
Cursor cursor = getActivity().getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, projection, selection, selectionArgs, null);
if (cursor != null) {
hasWhatsApp = cursor.moveToNext();
if (hasWhatsApp) {
whatsAppExists = 1;
}
cursor.close();
}
return whatsAppExists;
}
I am trying to create a Custom Contact app which displays only those contacts that have Contact Number. First of all, is there any automated way to do it? Suppose not, then I am trying to search a contact by its name e.g. Rohan.
Here is the code :-
Cursor photoCursor = getContentResolver().query(
android.provider.ContactsContract.Contacts.CONTENT_URI,
new String[] { ContactsContract.Contacts.PHOTO_ID,
ContactsContract.Contacts.DISPLAY_NAME },
ContactsContract.Contacts.DISPLAY_NAME + " = ?",
new String[]{"Rohan"}, null);
photoCursor.moveToFirst();
while (photoCursor.moveToNext()) {
Log.d("Photo Thumbnail", "" + photoCursor.getString(1));
}
Although the contact exists, I am not getting any Log, if I remove Selection & Selection Args I see Rohan in the log. What am I doing wrong?
Simple Solution for Searching Partial Display Name.
ContentResolver contentResolver = getCurrentActivity().getContentResolver();
String whereString = "display_name LIKE ?";
String[] whereParams = new String[]{ "%" + searchText + "%" };
Cursor contactCursor = contentResolver.query(
ContactsContract.Data.CONTENT_URI,
null,
whereString,
whereParams,
null );
while( contactCursor.moveToNext() ) {
int contactId = getIntFromCursor( contactCursor, ContactsContract.Data.CONTACT_ID );
Log.d( "Contact ID", contactId)
}
contactCursor.close();
I did it by using the following code
Cursor cursor = getContentResolver().query(
android.provider.ContactsContract.Contacts.CONTENT_URI,
new String[] { ContactsContract.Contacts.PHOTO_ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts._ID },
ContactsContract.Contacts.HAS_PHONE_NUMBER, null,
ContactsContract.Contacts.DISPLAY_NAME);
This cursor gives all the contacts that have any phone number and then i save the unique ID in an ArrayList like this
cursor.moveToFirst();
while (cursor.moveToNext()) {
contactsID.add(cursor.getString(2));
}
then on selecting the contact i find the contact numbers using this
Cursor cursor = getContentResolver()
.query(android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME },
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?",
new String[] { contactsID.get(position) }, null);
contactNumbers = new ArrayList<String>();
while (cursor.moveToNext()) {
contactNumbers.add(cursor.getString(0));
Log.d("number", cursor.getString(0));
}
Try this:
Cursor contactLookupCursor =
getContentResolver().query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode("Rohan")),
new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup.NUMBER},
null,
null,
null);
try {
while (contactLookupCursor.moveToNext()) {
contactName = contactLookupCursor.getString(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
contactNumber = contactLookupCursor.getString(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup.NUMBER));
}
} finally {
contactLookupCursor.close();
}
It looks like you are trying to implement a screen that will allow the user to select a contact, and then select a phone number of that contact.
If that's the case, you can use a phone-picker intent instead:
Intent intent = Intent(Intent.ACTION_PICK);
intent.setType(CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, REQUEST_SELECT_PHONE_NUMBER);
This will open the native Contacts app, and allow the user to select a contact, and a phone number.
You'll then receive the result in your app like this:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_SELECT_PHONE_NUMBER && resultCode == RESULT_OK) {
// Get the URI and query the content provider for the phone number
Uri contactUri = data.getData();
String[] projection = new String[]{CommonDataKinds.Phone.NUMBER};
Cursor cursor = getContentResolver().query(contactUri, projection,
null, null, null);
// If the cursor returned is valid, get the phone number
if (cursor != null && cursor.moveToFirst()) {
int numberIndex = cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER);
String number = cursor.getString(numberIndex);
// Do something with the phone number
...
}
}
}
I am trying to get all contacts in the favourites list of the Android contacts. Currently, I can get all the group ids including the favourite group ID. But it seems that there is no contacts that have the group ID as the favourite group ID.
I'm trying to get All groups id and contacts in each group. After printing two list, I found that the group id of favorite is not in the contact list
ArrayList<String> favGroupId=new ArrayList<String>();
final String[] GROUP_PROJECTION = new String[] {
ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
Cursor cursor = getContentResolver().query(
ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
null, ContactsContract.Groups.TITLE);
while (cursor.moveToNext()) {
String id = cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups._ID));
Log.v("Test",id);
String gTitle = (cursor.getString(cursor
.getColumnIndex(ContactsContract.Groups.TITLE)));
Log.v("Test",gTitle);
if (gTitle.contains("Favorite_")) {
gTitle = "Favorites";
favGroupId.add(id);
}
}
cursor.close();
You can use the STARRED field in the ContactsContract.Contact class. If you change your query to:
Cursor cursor = this.managedQuery(
ContactsContract.Contacts.CONTENT_URI, projection, "starred=?",
new String[] {"1"}, null);
this should return a list of all contacts that appear in the Favorites tab in the default Contacts app on Android.
Complete answer, including intentUriString for opening the contact with an Intent:
Map getFavoriteContacts(){
Map contactMap = new HashMap();
Uri queryUri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.STARRED};
String selection =ContactsContract.Contacts.STARRED + "='1'";
Cursor cursor = managedQuery(queryUri, projection, selection, null, null);
while (cursor.moveToNext()) {
String contactID = cursor.getString(cursor
.getColumnIndex(ContactsContract.Contacts._ID));
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI, String.valueOf(contactID));
intent.setData(uri);
String intentUriString = intent.toUri(0);
String title = (cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
contactMap.put(title,intentUriString);
}
cursor.close();
return contactMap;
}
Ty this with Kotlin:
import android.content.Context
import android.provider.ContactsContract
import android.content.Intent
import android.net.Uri
fun getFavoriteContacts(context: Context): Map<*, *> {
lateinit var contactMap : HashMap<String, String>
val queryUri = ContactsContract.Contacts.CONTENT_URI.buildUpon()
.appendQueryParameter(ContactsContract.Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true")
.build()
val projection = arrayOf(
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.STARRED
)
val selection = ContactsContract.Contacts.STARRED + "='1'"
val cursor = context.getContentResolver().query(queryUri,
projection, selection, null, null)
while (cursor.moveToNext()) {
val contactID = cursor.getString(cursor
.getColumnIndex(ContactsContract.Contacts._ID))
val intent = Intent(Intent.ACTION_VIEW)
val uri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_URI, contactID.toString())
intent.data = uri
val intentUriString = intent.toUri(0)
val title = cursor.getString(
cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME))
contactMap[title] = intentUriString
}
cursor.close()
return contactMap
}
Here is the complete method to get contact details with favorite in Java
ContentResolver contentResolver = context.getContentResolver();
if (contentResolver == null)
return;
String[] fieldListProjection = {
ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER,
ContactsContract.Contacts.HAS_PHONE_NUMBER,
ContactsContract.Contacts.PHOTO_URI
,ContactsContract.Contacts.STARRED
};
String sort = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY + " ASC";
Cursor phones = contentResolver
.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI
, fieldListProjection, null, null, sort);
HashSet<String> normalizedNumbersAlreadyFound = new HashSet<>();
if (phones != null && phones.getCount() > 0) {
while (phones.moveToNext()) {
String normalizedNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
if (Integer.parseInt(phones.getString(phones.getColumnIndex(
ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
if (normalizedNumbersAlreadyFound.add(normalizedNumber)) {
int id = phones.getInt(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
String name = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
int fav = phones.getInt(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.STARRED));
boolean isFav;
isFav= fav == 1;
String uri = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.PHOTO_URI));
if(uri!=null){
contactList.add(new FavContact(id,isFav,name,phoneNumber,uri));
}
else{
contactList.add(new FavContact(id,isFav,name,phoneNumber));
}
}
}
}
phones.close();
}