add handling for updating local private contacts

This commit is contained in:
tibbi 2018-02-11 20:50:08 +01:00
parent 097344dd26
commit dc43fb93f8
2 changed files with 10 additions and 1 deletions

View File

@ -328,7 +328,9 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
}
fun updateContact(contact: Contact, photoUpdateStatus: Int): Boolean {
return try {
return if (contact.source == SMT_PRIVATE) {
activity.dbHelper.update(contact)
} else try {
activity.toast(R.string.updating)
val operations = ArrayList<ContentProviderOperation>()
ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI).apply {

View File

@ -61,6 +61,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
return id != -1
}
fun update(contact: Contact): Boolean {
val contactValues = fillContactValues(contact)
val selection = "$COL_ID = ?"
val selectionArgs = arrayOf(contact.id.toString())
return mDb.update(CONTACTS_TABLE_NAME, contactValues, selection, selectionArgs) == 1
}
private fun fillContactValues(contact: Contact): ContentValues {
return ContentValues().apply {
put(COL_FIRST_NAME, contact.firstName)