Cursor cursor = db.rawQuery( //空指针
"select * from user_info where username=?",
new String[] { text });
while (cursor.moveToNext()) {
TextView username=(TextView)findViewById(R.id.nickname);
username.setText(cursor.getString(1));
EditText phone=(EditText)findViewById(R.id.phone);
phone.setText(cursor.getString(4));
cursor.close();
}
Cursor cursor = db.rawQuery( //空指针
"select * from user_info where username=?",
new String[] { text });
如果text是String类型,那么这句从语法上看是正确的。
问题极大可能是因为符合条件的记录 只有一条 。
while (cursor.moveToNext()) //如果记录只有一条,这句执行后,就指向null了。
修改方法:
.........
cursor.moveToFirst();
do{
//其它代码
} while(cursor.moveToNext());
用心回答每个问题,如果对您有帮助,请采纳答案好吗,谢谢。
看你Edit_Info类第40行代码,分析下哪个对象可能为空