什么是错我的是Android 4.3的ContentProvider? [英] What is wrong with my ContentProvider in Android 4.3?

查看:141
本文介绍了什么是错我的是Android 4.3的ContentProvider?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序的工作方式与任何Android版本罚款之前 4.3 。我的意思是,当我输入一个字到 edWord (EditText上域),同样的拼写单词的列表将出现在列表视图中。

My app works just fine with any Android version before 4.3. I mean when I input a word into edWord (EditText field), a list of similarly-spelled words will appear in the list view.

的Andr​​oid 4.3 ,它总是返回,声称app_ContentProvider找不到支持 URI

But in Android 4.3, it always returns null, claiming that app_ContentProvider cannot find the supported uri.

我用下面的code键来显示单词列表:

I use the following code to show the word list:

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的从正常运行停止我的应用程序的任何更改。

I have no idea whether there are any changes in Android 4.3 that stop my app from functioning normally.

对于我的code线上面,可以请你告诉我,这个问题可能是什么?非常感谢。

Regarding my code lines above, can you please tell me what the problem might be? Thanks a lot.

推荐答案

尝试设置属性的android:出口=真在你的清单内容提供商。看来,这个属性的默认值是Android 4.3已经改变了

Try set the property android:exported="true" for your content provider in your Manifest. It seems that the default value of this property has changed in android 4.3

这篇关于什么是错我的是Android 4.3的ContentProvider?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆