Android; Pulling out contact info, should you map to custom domain class or is there one provided?
When picking out contact details, is there a built in domain class they can be mapped to? Or, do you have to create your own?
For example I do the following :
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
String s = null;
if (cursor.getCount() > 0)
{
while (cursor.moveToNext())
{
开发者_如何学JAVA s = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
}
}
With s
, can I put that into a "contact" object/domain class, perhaps something like :
Contact myContact = new Contact();
myContact.setName(s);
AFAIK There is no built in Contacts class, besides with extensible Contacts model in android it will soon become a Bean around CommonDataKinds plus Map for everything else, besides I believe it's also true for the most of data provided by Android SDK They give you access to Data how you handle it is yours choice
精彩评论