2009-06-16 7 views
0

J'ai un curseur sur un contact. Comment puis-je obtenir une URL construite à partir de ce curseur?Comment puis-je obtenir une URL à partir d'un objet curseur

J'ai besoin de savoir parce que d'ici http://developer.android.com/guide/topics/providers/content-providers.html

je dois avoir une url pour que je puisse construire un uri de téléphone, comme ceci:

phoneUri = Uri.withAppendedPath (uri, gens. Phones.CONTENT_DIRECTORY);

et je peux interroger tous les numéros de téléphone pour ce contact.

Répondre

1

Vous pouvez utiliser la requête suivante pour récupérer tous les numéros pour un contact spécifique:

/* the following line assumes that the contactCursor you described 
* has the People._ID column at index 0 in its projection. */ 
int contactId = contactCursor.getInt(0); 

Cursor numberCursor = getContentResolver().query(Phones.CONTENT_URI, 
    new String[] {Phones.NUMBER}, Phones.PERSON_ID + "=" + contactId, null, null); 
while(cursor.moveToNext()) { 
    String number = cursor.getString(0); 
} 
cursor.close();
Questions connexes