The ContactsUtils class allows you to read and modify the stored contacts.
The current version is an early beta. There are still some features missing.
However you can already play with it and go over the code.
It requires the new ContentResolver library: [library] ContentResolver
Types:
All the Findxxx methods return a List with cuContact items:
Get fields:
Set / Add methods:
More methods will be available in the final version.
It should also be relatively simple to extend the code.
The current version is an early beta. There are still some features missing.
However you can already play with it and go over the code.
It requires the new ContentResolver library: [library] ContentResolver
Types:
B4X:
Type cuContact (Id As Long, DisplayName As String)
Type cuEmail (Email As String, EmailType As String)
Type cuPhone (Number As String, PhoneType As String)
All the Findxxx methods return a List with cuContact items:
B4X:
Public Sub FindContactsByName(Name As String, Exact As Boolean, VisibleOnly As Boolean) As List
Public Sub FindContactsByMail(Mail As String, Exact As Boolean, VisibleOnly As Boolean) As List
Public Sub FindContactsByNotes(Note As String, Exact As Boolean, VisibleOnly As Boolean) As List
Public Sub FindContactsByPhone(PhoneNumber As String, Exact As Boolean, VisibleOnly As List
Public Sub FindContactsByStarred(Starred As Boolean) As List
Public Sub FindContactsWithPhotos As List
Get fields:
B4X:
'Returns a List with cuEmail items.
Public Sub GetEmails(Id As Long) As List
'Returns a List with cuPhone items.
Public Sub GetPhones(id As Long) As List
'Returns the note field.
Public Sub GetNote(id As Long) As String
'Returns the thumbnail photo of the given contact. Returns an uninitialized bitmap if no photo is available.
Public Sub GetPhoto(Id As Long) As Bitmap
Set / Add methods:
B4X:
'Sets the note field of the given id.
Public Sub SetNote(Id As Long, Note As String)
'Adds an email field to the given contact id.
Public Sub AddEmail(Id As Long, Email As String, EmailType As String)
More methods will be available in the final version.
It should also be relatively simple to extend the code.