Android Question How to update contacts numbers

Discussion in 'Android Questions' started by Marco Gioia, May 24, 2019.

  1. Marco Gioia

    Marco Gioia Member Licensed User

    Hi all,

    to update the displayname I used this link: https://www.b4x.com/android/forum/threads/update-contact-displayname.76313/#post-484270

    Code:
    Public Sub SetDisplayName(Id As Long, Name As String)
       
    Dim values As ContentValues
       values.Initialize
       values.PutString(
    "data1", Name)
       SetData(
    "vnd.android.cursor.item/name", values, IdTrue)
    End Sub
    Is there something similar for phone?

    I guess I can't use "vnd.android.cursor.item/phone" due to "numbers"
     
  2. klaus

    klaus Expert Licensed User

    Add this routine to the ContactUtils Class:
    Code:
    'PhoneTypeIndex = the index number of the phone type
    '"1" = "home"
    '"2" = "mobile"
    '"3" = "work"
    '("4" = "fax_work"
    '"5" = "fax_home"
    '"6" = "pager"
    '"7" = "other"
    '"8" = "callback"
    '"9" = "car"
    '"10" = "company_main"
    '"11" = "isdn"
    '"12" = "main"
    '"13" = "other_fax"
    '"14" = "radio"
    '"15" = "telex"
    '"16" = "tty_tdd"
    '"17" = "work_mobile"
    '"18" = "work_pager"
    '"19" = "assistant"
    '"20" = "mms")
    Public Sub SetPhone(Id As Long, PhoneNumber As String, PhoneTypeIndex As String)
        
    Dim values As ContentValues
        values.Initialize
        values.PutString(
    "data1", PhoneNumber)
        values.PutString(
    "data2", PhoneTypeIndex)
        SetData(
    "vnd.android.cursor.item/phone_v2", values, IdTrue)
    End Sub
    Calling example:
    "1" for "home"
    Code:
    cu.SetPhone(CurrentID, edtPhoneNumber.Text, "1")
    Information source:
    https://www.dev2qa.com/android-contacts-fields-data-table-columns-and-data-mimetype-explain/
     
    Last edited: May 24, 2019
    DonManfred and Erel like this.
  3. Marco Gioia

    Marco Gioia Member Licensed User

    It works!
    Thank you so much :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice