Reputation: 21
i want to get number from name that i select from spinner how can i do.i think first i want to id for particular name.can any one help me.
public void onItemSelected(AdapterView parent, View arg1, int pos, long arg3)
{
String name,phoneNumber;
name=parent.getItemAtPosition(pos).toString();
String[] projection1 = new String[]{
People._ID,People.NAME,People.NUMBER
};
Cursor cur=getContentResolver().query(People.CONTENT_URI, projection1,People.NAME+"="+name , null, null);
phoneNumber=cur.getString(cur.getColumnIndex(People.NUMBER));
Toast.makeText(parent.getContext(), "number="+phoneNumber,Toast.LENGTH_LONG).show();
/* cur.moveToFirst();
if(cur.moveToFirst())
{
do
{
}while(cur.moveToNext());
}*/
}
Upvotes: 0
Views: 155
Reputation: 12444
when you read the Contacts
for the first time, save them to ArrayList
, make your Custom Class
to hold necessary information about each Contact
like name and number, then put them into HashTable<String,CustomClass>
, the key is the Contact
number, then you can quickly get it from the HashTable
Upvotes: 0