B4A Library [class] ContactsUtils - Provides read / write access to the stored contacts

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jul 7, 2013.

  1. JOTHA

    JOTHA Well-Known Member Licensed User

    Is it possible to get really every information out of my contacts (f.e: spouse, etc.)?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There is no simple "dump" method that exports all the data.

    Not all fields are exposed. However it shouldn't be difficult to access more data (see how ContactsUtils class is built).
     
    JOTHA likes this.
  3. JOTHA

    JOTHA Well-Known Member Licensed User

    Thank you Erel ...
     
  4. JOTHA

    JOTHA Well-Known Member Licensed User

    ... another problem:
    I want to get the first 4 phone numbers from a contact to write them in 4 fields.
    The code to get these 4 phone numbers ...
    Code:
    For Each phone As cuPhone In ContactsUtils1.GetPhones(Kontakt.Id)
            
    Dim Kontakte_Telefon_1,  Kontakte_Telefon_2, Kontakte_Telefon_3, Kontakte_Telefon_4 As String
            Kontakte_Telefon_1 = ContactsUtils1.GetPhones(Kontakt.Id).Get(
    0)
            Kontakte_Telefon_2 = ContactsUtils1.GetPhones(Kontakt.Id).Get(
    1)
            Kontakte_Telefon_3 = ContactsUtils1.GetPhones(Kontakt.Id).Get(
    2)
            Kontakte_Telefon_4 = ContactsUtils1.GetPhones(Kontakt.Id).Get(
    3)
                
    Log(""&phone.Number&"")
        
    Next
    The result is not the solution which I'm looking for ...
    Only in the Log I can get the telephone numbers, but how can I get a result that looks like this:

    Kontakte_Telefon_1 = PhoneNumber_1
    Kontakte_Telefon_2 = PhoneNumber_2
    Kontakte_Telefon_3 = PhoneNumber_3
    Kontakte_Telefon_4 = PhoneNumber_4

    Any idea?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  6. JOTHA

    JOTHA Well-Known Member Licensed User

    OK Erel ... ;-)
     
  7. desof

    desof Well-Known Member Licensed User

    ES: Y como es posible agregar un nuevo contacto ?
    EN: And how is it possible to add a new contact?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    With InsertContact (see the first post).
     
  9. beacon

    beacon Member Licensed User

    B4A: I can add a new contact to the phone's contacts list successfully with ContactUtils and ContentResolver Ver 1.50.

    Is there please a method to add a photograph to a contact?

    Thank you.
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    Yes. Please start a new thread in the questions forum and I'll show you the code.
     
  11. Dogbonesix

    Dogbonesix Active Member Licensed User

    Is there a way to edit the display name? Especially helpful for typing error. It is reasonably easy to change everything else except the display name.
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  13. stanks

    stanks Active Member Licensed User

    hm i have a permission problem. yesterday my app worked fine but i have upgraded my s7 with official oreo (v8) now i get error msg
    Code:
    java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{...} (pid=21476, uid=10403) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
    and i have that 2 permission in manifest
    Code:
    AddPermission(android.permission.READ_CONTACTS)
    AddPermission(android.permission.WRITE_CONTACTS) 
    'if write access is required
    i treid with uninstall "old" version of my app from device then new install but failure too

    any idea?

    thanks
     
  14. DonManfred

    DonManfred Expert Licensed User

    You should start a NEW thread for your Issue. It is probably not related to this tutorial.
    This two Permissions are Dangerous Permissions.
    [​IMG]

    TargetSDK
    Especially you should check RuntimePermissions.
     
  15. stanks

    stanks Active Member Licensed User

    am i safe to use my "smart" phone at all?
    target is set to 26...
     
  16. DonManfred

    DonManfred Expert Licensed User

    You should start a new thread for any new Question you have. It does work with Target 26. But you need to know the consequences of using TargetSDK 26
     
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