嗨,我是 android 编程新手,我不知道或者我真的无法弄清楚为什么在我单击我创建的应用程序上的按钮后会收到此错误消息
java.lang.NullPointerException at com.example.dailydoseofhappiness.MainActivity.searchRecord(MainActivity.java:62) at com.example.dailydoseofhappiness.MainActivity.searchRecord(MainActivity.java:52)
这是代码片段。
public void onClick(View arg){
if(arg.getId()==R.id.btnfortune){ //this is line 52
searchRecord(count);
}
}
public void searchRecord(int count)
throws SQLException
{
Cursor rsCursor;
String [] rsFields = {"mesNum","Message"}; // this is line 62
rsCursor = dbm.dbase.query("MessageFile", rsFields, "mesNum = " + count, null, null, null, null, null);
rsCursor.moveToFirst();
if(rsCursor.isAfterLast()==false){
lblmessageS.setText(rsCursor.getString(0));
}
rsCursor.close();
}
如果有什么问题,谁能检查这个代码片段非常感谢