From 0960b28e02b38892766e0dabe8bace7341c19125 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 26 Mar 2019 06:52:46 +0000 Subject: [PATCH] Backward compatibility --- .../java/eu/faircode/email/ActivitySetup.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivitySetup.java b/app/src/main/java/eu/faircode/email/ActivitySetup.java index f9b0937eee..a07408123b 100644 --- a/app/src/main/java/eu/faircode/email/ActivitySetup.java +++ b/app/src/main/java/eu/faircode/email/ActivitySetup.java @@ -702,14 +702,16 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On } // Contacts - JSONArray jcontacts = jaccount.getJSONArray("contacts"); - for (int c = 0; c < jcontacts.length(); c++) { - JSONObject jcontact = (JSONObject) jcontacts.get(c); - EntityContact contact = EntityContact.fromJSON(jcontact); - contact.account = account.id; - if (db.contact().getContact(contact.account, contact.type, contact.email) == null) { - contact.id = db.contact().insertContact(contact); - Log.i("Imported contact=" + contact); + if (jaccount.has("contacts")) { + JSONArray jcontacts = jaccount.getJSONArray("contacts"); + for (int c = 0; c < jcontacts.length(); c++) { + JSONObject jcontact = (JSONObject) jcontacts.get(c); + EntityContact contact = EntityContact.fromJSON(jcontact); + contact.account = account.id; + if (db.contact().getContact(contact.account, contact.type, contact.email) == null) { + contact.id = db.contact().insertContact(contact); + Log.i("Imported contact=" + contact); + } } }