2010-10-02 81 views
0
I have one function which is called on list item Click and list items contain 
name and phone Numbers,i Use the following query,but what query Should i use 
retrieve particular phone Number That Matches (Long id) 

protected void onListItemClick (ListView l, View v, int position, long id) 
{ 

    try 
    { 
    String[] PROJECTION=new String[] {Contacts._ID, 
      Contacts.DISPLAY_NAME, 
      Phone.NUMBER 
     }; 
    Cursor c=managedQuery(Phone.CONTENT_URI, 
     PROJECTION, "where _ID == id ", null, null); 
    System.out.println(Phone.NUMBER); 
    c.close(); 
    } 
    catch(Exception e) 
    { 
     e.printStackTrace(); 

    } 
    for(int i=0;i<=position;i++) 
    { 


     if(position==i) 
     { 
      Intent i1 = new Intent(v.getContext(),SMS.class); 
      startActivity(i1); 


     } 



} 

回答

0

1)Cursor INSTEAOD C = managedQuery(Phone.CONTENT_URI,PROJECTION,「where _ID == id」,null,null); 請嘗試:Cursor c = managedQuery(Phone.CONTENT_URI,PROJECTION,「_id == xxx」,null,null);

2)添加到表現:

3)c.close()之前使用 c.moveToFirts(); c.getString(2); //電話號碼

希望這會有幫助