How can I get contact name with his/her number

前端 未结 4 1740
情话喂你
情话喂你 2021-02-12 13:47

I\'m trying to develop a simple app using Android Scripting and Python.

Now, I have a phone number, and I want to find out which contact has that number. I can do a con

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-12 14:27

    You might want to take a look at the ContactsContract data table. Query it with something like this:

        Cursor c = getContentResolver().query(Data.CONTENT_URI,
             new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
                           Data.RAW_CONTACT_ID + "=?" + " AND "
                           + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
                           new String[] {String.valueOf(rawContactId)
             }, null)
    

提交回复
热议问题