Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
CB-11043: Android App crashes while trying to save contact with phone…
Browse files Browse the repository at this point in the history
… numbers array with deleted values

 This closes #121
  • Loading branch information
sarangan12 authored and riknoll committed Apr 12, 2016
1 parent 0f8945b commit d7dd937
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ for details.
myContact.save(function (contact_obj) {
var contactObjToModify = contact_obj.clone();
contact_obj.remove(function(){
// Note: Do NOT use delete operator to remove the phone numbers. It will break in android.
var phoneNumbers = [contactObjToModify.phoneNumbers[0]];
contactObjToModify.phoneNumbers = phoneNumbers;
contactObjToModify.save(function(c_obj){
Expand Down
6 changes: 4 additions & 2 deletions src/android/ContactAccessorSdk5.java
Original file line number Diff line number Diff line change
Expand Up @@ -1701,8 +1701,10 @@ private String createNewContact(JSONObject contact, String accountType, String a
phones = contact.getJSONArray("phoneNumbers");
if (phones != null) {
for (int i = 0; i < phones.length(); i++) {
JSONObject phone = (JSONObject) phones.get(i);
insertPhone(ops, phone);
if(!phones.isNull(i)){
JSONObject phone = (JSONObject) phones.get(i);
insertPhone(ops, phone);
}
}
}
} catch (JSONException e) {
Expand Down

0 comments on commit d7dd937

Please sign in to comment.