2 kluing kluing 于 2014.06.12 10:26 提问

为什么点击文本查询单词就闪退

就是我把别人低版本的词典源代码原装复制过来结果一查单词就闪退,告诉我访问不了数据库。但是我把数据库已经复制过来了呀!下面是报错的地方

05-23 10:14:13.195: E/AndroidRuntime(5635): java.lang.NullPointerException

05-23 10:14:13.195: E/AndroidRuntime(5635): at com.example.nnnnn.Main.afterTextChanged(Main.java:91)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.widget.TextView.sendAfterTextChanged(TextView.java:7095)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:8743)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:970)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:497)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:435)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:30)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:672)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:196)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:279)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 10:14:13.195: E/AndroidRuntime(5635): at android.app.ActivityThread.main(ActivityThread.java:4928)
05-23 10:14:13.195: E/AndroidRuntime(5635): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 10:14:13.195: E/AndroidRuntime(5635): at java.lang.reflect.Method.invoke(Method.java:511)
05-23 10:14:13.195: E/AndroidRuntime(5635): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-23 10:14:13.195: E/AndroidRuntime(5635): at dalvik.system.NativeStart.main(Native Method)
点击之后报了这里错误:
public void afterTextChanged(Editable s) {
//查询错了
Cursor cursor=database.rawQuery("" +
"select english as _id from t_words where english like ?",
new String[]
{ s.toString() + "%" });
DictionaryAdapter dictionaryAdapter = new DictionaryAdapter(this,
cursor, true);
actvWord.setAdapter(dictionaryAdapter);

    }

有没有哪位大牛 教下我!谢谢

1个回答

qwuack
qwuack   2014.06.28 22:02

数据库连接串有没有问题?

kluing
kluing 谢谢你回答哈!我知道为什么出错了。因为以前低版本查sd卡不用权限,高版本需要了
接近 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!