1

with reference to the following thread..

Can't see contacts that was saved with phonegap on android

i want to ask that. i am saving contacts from my phonegap app to Xperia J. But i can not see the saved contacts. However when i m retrieving the saved contact and printing it in alert, i can see it.

What is wrong? Can anyone please help? Thanks in advance !

Community
  • 1
  • 1

1 Answers1

0

First add few contact in your device ...

<script type="text/javascript" charset="utf-8">

 document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // find all contacts with 'Bob' in any name field
    var options = new ContactFindOptions();
    options.filter="Bob"; 
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, onSuccess, onError, options);

unction onSuccess(contacts) {
    for (var i=0; i<contacts.length; i++) {
        console.log("Display Name = " + contacts[i].displayName);
    }
}



 // onError: Failed to get the contacts
//
function onError(contactError) {
    alert('onError!');
}


}

</script>
Darshan
  • 2,272
  • 3
  • 31
  • 43
  • Hi Gamex.. i have added contacts in my phone and then used your script to retrieve it.. i am able to see the contacts. But my question is when i am saving a contact from my phonegap application then i am not able to view in my contact list, although i can retrieve it by using a similar script like yours.. – Manu Khullar Nov 22 '13 at 11:32
  • Yes, you can follow above script for retrive contact – Darshan Nov 22 '13 at 11:55
  • 1
    did u check ontacts.length ? –  Nov 22 '13 at 11:59
  • @ Darshan.. yes.. i can alert the name of the contact also.. but its not showing in my mobile contacts list !! – Manu Khullar Nov 26 '13 at 04:45
  • Same problem occurs in xperia-U. – Dinesh Dabhi Jul 04 '14 at 06:28