From 7aa9cfa3287176284f1f6aab78b407f90e410826 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Apr 2020 22:04:39 +0200 Subject: [PATCH] adding a weird workaround or what at storing contacts on a SIM card --- .../contacts/pro/helpers/ContactsHelper.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt index c49cb638..440aeef1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt @@ -1325,6 +1325,17 @@ class ContactsHelper(val context: Context) { val results: Array try { results = context.contentResolver.applyBatch(AUTHORITY, operations) + + // storing contacts on some devices seems to be messed up and they move on Phone instead, or disappear completely + // try storing a lighter contact version with this oldschool version too just so it wont disappear, future edits work well + if (getContactSourceType(contact.source).contains(".sim")) { + val simUri = Uri.parse("content://icc/adn") + ContentValues().apply { + put("number", contact.phoneNumbers.firstOrNull()?.value ?: "") + put("tag", contact.getNameToDisplay()) + context.contentResolver.insert(simUri, this) + } + } } finally { scaledSizePhotoData = null }