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

Status
Not open for further replies.

hzytsoft

Member
Licensed User
Longtime User
hi Erel


i use this code
Dim c As cuContact

c=cu.InsertContact("jim","1234567890")
ToastMessageShow(c.Id, False)
cu.AddPhone(c.Id,"87909877","home")
but got wrong
then i use this code
cu.AddPhone(c.Id,"87909877","1")

also got wrong
===============
logs show:
java.lang.IllegalArgumentException: Invalid column name_raw_contact_id

pls
 

hzytsoft

Member
Licensed User
Longtime User
B4X:
Sub Button1_Click
Dim c As cuContact

  c=cu.InsertContact("jim","1234567890")
  ToastMessageShow(c.Id, False)
  cu.AddPhone(c.Id,"87909877","home")
End Sub
 

shaffnert03

Member
Licensed User
Longtime User
Don't mean to jump in front of hzytsoft's question, but have one for after his is answered.

Trying to use the new getevents() function (thanks so much for adding that BTW!), and having some issues getting the information out. If I put the result into a cuEvents object I can get data out when it's populated, but if the contact has no event data I can't seem to check for that.

IsInitialized doesn't work since I had to initialize the variable before pulling it (didn't work if I tried not to), and if try to check and see if "EventType" is <> "" then the program bombs out. Log shows "Error occurred on line: 118 (contactsutils) importcontactsafterFirstLayout (java line: 98)"

As an alternative I tried to put the getevents result in a normal list. I could then put the items from that into an object, but nothing I put in the get function on the object seemed to get the data out.

Any help with this? Here's a few lines that I'm trying as a visual:

B4X:
Dim EventList As cuEvent
    EventList.Initialize
EventList = cu.GetEvents(Contact.Id)
    If EventList.EventType = "birthday" Then lbl2.Text = EventList.DateString

Also, more generally, this is like the third or fourth question I've had on just getting data out of various data types, is there somewhere particular you'd recommend I go for more information on this? I've got both user manuals and the Kindle book on B4A, anywhere in particular I should look to understand this better?
 

HARRY

Active Member
Licensed User
Longtime User
Hi,

I use this class with pleasure, it works very well. However, it does not do all things I need. I have to extract the postal address of a contact from which I know the iD.

In the first post Erel says:It should be pretty simple to extend this class and retrieve or modify other fields based on the existing code.

For me, however, it is not "pretty simple"; whatever I try, based on studying various sources on internet, I do not reach my goal.

Can somebody give me some help?


Harry
 

HARRY

Active Member
Licensed User
Longtime User
Hi Erel,

Thanks very much. It works without problems. I was looking in the same direction, but did not know how to handle raw.

Harry
 

aklisiewicz

Active Member
Licensed User
Longtime User
Using Android 4.3+
I would like to know how can I use this LIB to display Contacts in my Application based on the selected contact group.
I do not see any GROUP property in the lib referenced...

I would like to have a SIPNNER which allows the user to select a GROUP, then use ListView (or alike) to display contacts based on that group.

Arthur
 

derez

Expert
Licensed User
Longtime User
The names of the contacts are cut when their length exceeds ~12-14 characters. It comes like this from the cr.Query - crsr.GetString("display_name").
Any reason for this ?
 

derez

Expert
Licensed User
Longtime User
You can try to fetch the name from this uri: vnd.android.cursor.item/name
I get the same thing with the above , both on nexus 5 and samsung 2.
 

derez

Expert
Licensed User
Longtime User
I guess the problem is from transfering the contacts to and from sim cards. I'll check later with a new contact.
Edit: it is like I wrote above. If I update the contact it shows in full.
 
Last edited:

aklisiewicz

Active Member
Licensed User
Longtime User
Note that this is not a library, it is a class module.

ContactsUtils currently doesn't provide access to contacts groups.


any chance to get groups support in a near future ?
Is there any other way to filter through groups ?
Art
 

Gennaro Frungillo

Member
Licensed User
Longtime User
Hi Erel, i've a question:
it's possible to load all contact into a listview inside an async operation?
Let me explain, I need to load all the address book contacts in a listview with their images, but the operation takes enough time, it would be nice to load the contacts in the list asynchronously in order to give the user the possibility of immediate access to the form that contains the listview, without having to wait for loading of all contacts.
With visual studio I used the component BackGroundWorker or threading class.
 

CapReed

Member
Licensed User
Longtime User
I have spent several hours this item, It is very rare ...

I added this sub to update the contact name.

B4X:
Public Sub PonNombre(Id As Long, Name As String)
    Dim v As ContentValues
    v.Initialize
    v.PutString("data1", Name)
    SetData("vnd.android.cursor.item/name", v, Id, True)
End Sub

Works fine, but there is one detail that I do not understand.
Suppose that the contact old name was MiNameIs Anthony
Suppose that the contact new name is Ama
Well, the result after executing the subroutine is that Ama Anthony appears in the address book
I do not understand ...

Can you help me????
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…