我的应用程序适用于之前的任何 Android 版本4.3
。我的意思是当我在(EditText 字段)中输入一个单词时edWord
,列表视图中会出现一个拼写相似的单词列表。
但是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
会阻止我的应用程序正常运行。
关于我上面的代码行,你能告诉我可能是什么问题吗?非常感谢。