Question

I have a small app, just user choose one contact in the contact list and its Mobile phone number will print to screen.

So, after a use click to one contact in list, it will return an URI object contain information about this user. And I put some query to process.

Here is my simple query:

    Cursor phoneCursor = getContentResolver().query(uri, new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER}, 
                            ContactsContract.CommonDataKinds.Phone.TYPE+"="+ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE, 
                            null, null); //uri: URI Object return when user choose one contact
if (phoneCursor.moveToFirst()){
            String phoneNumber = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
        }

But when I run to this code, LogCat show error:

1)DatabaseUtils.readExceptionFromParcel

2)Error at :

 ontactsContract.CommonDataKinds.Phone.TYPE+"="+ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE,

I don't think my query has "grammar mistake" because I have checked carefully and LogCat doesn't show error that.

Please help me solve this problem.

thanks :)

Was it helpful?

Solution

You should see at line:

new String[]{ContactsContract.CommonDataKinds.Phone.NUMBER

When I debug, LogCat see that error first from this point. (this is a string constant and equal to "data1"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top