无法访问Android内容提供商

时间:2013-05-14 02:48:23

标签: android android-contentprovider

我可以在LogCat中看到ActivityManager正在报告某个特定内容提供商的内容。我使用以下代码尝试访问该内容提供程序,以便了解有关它的更多信息:

    Cursor cursor = context.getContentResolver().query(uriDSDS, null, null, null, null); 

    String[] columnNames = cursor.getColumnNames();        
    Log.d(TAG, "columnNames=" + columnNames.toString());

不幸的是,在尝试获取光标后,我在LogCat中看到以下错误:

  

无法找到 __

的提供者

有什么问题?为什么我无法访问此提供商?可能是访问仅限于某些应用程序?有没有办法进入ADB或其他东西,以查看设备上的所有可用内容提供商?

2 个答案:

答案 0 :(得分:0)

确保添加正确的Uri 例如

Uri uriDSDS = Uri.parse(                     “内容://aaa.aaa/values”);

答案 1 :(得分:0)

如下面的工作示例所示,请检查您的uriDSDS是否正确。

Cursor people = getContentResolver().query(
                        ContactsContract.Contacts.CONTENT_URI, null, null, null,
                        null);

                // get contact id
                while (people.moveToNext()) {
                    if (people != null) {
                        int numberFieldColumnIndex = people
                                .getColumnIndex(PhoneLookup._ID);
                        String number = people.getString(numberFieldColumnIndex);
                        contactId.add(number);
                    }
                }

                people.close();
相关问题