开发者

Android Cotent Provider

开发者 https://www.devze.com 2023-01-18 06:23 出处:网络
I have one functionwhich 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
 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<=posi开发者_Go百科tion;i++)
    {   


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


        }   



}


1) INSTEAOD OF Cursor c=managedQuery(Phone.CONTENT_URI, PROJECTION, "where _ID == id ", null, null); TRY THIS: Cursor c=managedQuery(Phone.CONTENT_URI, PROJECTION, "_id == xxx", null, null);

2) add to manifest:

3) before c.close() use c.moveToFirts(); c.getString(2); // Phone number

Hope this will help

0

精彩评论

暂无评论...
验证码 换一张
取 消