inserting email address into ContactMethods table in 0.9 beta

by kingkung » Sat, 30 Aug 2008 09:46:07 GMT


Sponsored Links
 For whatever reason, I'm having trouble inserting email addresses into
the ContactMethods table in 0.9... the code worked perfectly fine in
m5.

The insert() call is successful (no exception), but it consistently
says that 0 rows have been inserted.  These are the values that I set
in my ContentValues object:

cv = new ContentValues();
cv.put(ContactMethods.KIND,KIND_EMAIL); //KIND_EMAIL is an integer (1)
cv.put(ContactMethods.PERSON_ID, ac.mobileID); //long
cv.put(ContactMethods.DATA, email.value); //string
cv.put(ContactMethods.TYPE, email.type); //integer btwn 0-3
int rows =
context.getContentResolver().bulkInsert(getMethodUri(personUri),generateAddressCVarray(ac));
Logger.log(rows);

private static Uri getMethodUri(Uri contactUri)
{
        return
contactUri.buildUpon().appendPath(ContactMethods.CONTENT_URI.getLastPathSegment()).build();
}

Is there something I'm missing or something else that I need to set?
As I said before, this worked perfectly fine in m5.


--~--~---------~--~----~------------~-------~--~----~



inserting email address into ContactMethods table in 0.9 beta

by kingkung » Sat, 30 Aug 2008 09:50:17 GMT


 Slightly confusing code... the ContentValues properties (below) are
set in the method generateAddressCVarray(), which generates an array
of CVs for each email address...

cv = new ContentValues();
cv.put(ContactMethods.KIND,KIND_EMAIL); //KIND_EMAIL is an integer (1)
cv.put(ContactMethods.PERSON_ID, ac.mobileID); //long
cv.put(ContactMethods.DATA, email.value); //string
cv.put(ContactMethods.TYPE, email.type); //integer btwn 0-3

...........

The following line is then called for a bulkInsert... and the rows
always come out as 0.  Even if I insert them one at a time, I get the
same result.

int rows =
context.getContentResolver().bulkInsert(getMethodUri(personUri),generateAddressCVarray(ac));
Logger.log(rows);

private static Uri getMethodUri(Uri contactUri)
{
 return
contactUri.buildUpon().appendPath(ContactMethods.CONTENT_URI.getLastPathSegment()).build();
}

Can anyone help?
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


inserting email address into ContactMethods table in 0.9 beta

by Jeff Hamilton » Sat, 30 Aug 2008 09:54:14 GMT


 Does anything show up in the log when you see the failure?

-Jeff




--~--~---------~--~----~------------~-------~--~----~



inserting email address into ContactMethods table in 0.9 beta

by kingkung » Wed, 03 Sep 2008 01:21:31 GMT


 It's not a failure, it's just that 0 addresses are added.




--~--~---------~--~----~------------~-------~--~----~



inserting email address into ContactMethods table in 0.9 beta

by kingkung » Wed, 03 Sep 2008 04:09:11 GMT


 Never mind, my types are set to "0", and there is no "0" type anymore.





--~--~---------~--~----~------------~-------~--~----~