The format for vcard fields is KEY[;Attribute]:VALUE[;ATTRIBUTE]
. It looks like a typo in X-CUSTOMFIELD and should read X-CUSTOMFIELD:5555
Then you can use line.split(":")
on each line to get keys and values.
EDIT
First I'd read all lines from the file/message and store them as key/value paris in a Hashtable (HashMap is not available on android..). Use the split function I mentioned above to split the line into a key and a value part.
After this is done, simple ask the hashtable for the value for key "X-CUSTOMFIELD" and it should return "5555". (Assuming, you corrected the vcard format, I'm still positive that the X-CUSTOMFIELD line is invalid!)
EDIT 2
If vcard allows duplicate keys, then you still can use a hashtable as an internal vcard model but the value should be a List<String>
type rather then a String
and the vcard values are added to this list, like:
Hashtable<String, List<String>> vcard = new Hashtable<String, List<String>>();
for (String line:lines) { // assuming lines is an array or collection with all rows
String keyValuePair = line.split(":");
List<String> values = vcard.get(keyValuePair[0]);
if (values == null) {
// first value for this key - need to create the list
values = new ArrayList<String>();
vcard.put(keyValuePair[0], values);
}
values.add(keyValuePair[1]);
}
(untested - if it doesn't compile, treat it as pseudo-code ;-) )