Android 4.3中的ContentProvider出了什么问题?

时间:2013-11-08 09:33:07

标签: java android uri

我的应用程序适用于4.3之前的任何Android版本。我的意思是当我在edWord(EditText字段)中输入一个单词时,列表视图中会出现一个拼写相似的单词列表。

但在Android 4.3中,它始终返回null,声称app_ContentProvider找不到支持的uri

我使用以下代码来显示单词列表:

public void showWordlist() {    

    edWord.setEnabled(true);
    String word = edWord.getText().toString();      
    Uri uri = Uri.parse("content://doyle.app_name.app_ContentProvider/dict/" + mDBFile.fileName + "/list/" + word);
    edWord.requestFocus();

    try
    {
        Cursor result = getContentResolver().query(uri,null,null,null,null);    
        Log.i(MAIN_TAG, "Found word = " + result); 
        //I think the problem lies somewhere here because 
        //the 'result' is always 'null' (see the above log.i)

        if (result != null)
        {
            int countRow=result.getCount();
            Log.i(MAIN_TAG, "countRow = " + countRow);
            mLSTCurrentWord.clear();
            //mLSTCurrentContent.clear();
            mLSTCurrentWordId.clear();
            mAdapter.clear();
            if (countRow >= 1)
            {
                int indexWordColumn = result.getColumnIndex("word");
                int indexIdColumn = result.getColumnIndex("id");                
                result.moveToFirst();
                String strWord;
                int intId;
                int i = 0;
                do
                {                       
                    strWord = Utility.decodeContent(result.getString(indexWordColumn));
                    intId = result.getInt(indexIdColumn);                       
                    mLSTCurrentWord.add(i,strWord);
                    mLSTCurrentWordId.add(i,intId);
                    //mLSTCurrentContent.add(i,strContent);
                    mAdapter.add(strWord);
                    i++;
                } while (result.moveToNext()); 
            }

            result.close();
        }

        lstWord.setAdapter(mAdapter);
    }
    catch (Exception ex)
    {
        Log.e(MAIN_TAG, "Error = " + ex.toString());  
    }
    edWord.setEnabled(true);        
}

这是我的app_ContentProvider

我不知道Android 4.3是否有任何更改阻止我的应用正常运作。

关于上面的代码行,您能否告诉我问题可能是什么?非常感谢。

1 个答案:

答案 0 :(得分:0)

尝试设置属性android:exported =" true"为您的Manifest中的内容提供商。看来这个属性的默认值在android 4.3中已经改变了