模拟器运行正常,在真机测试出错。异常如下:
我的cursor初始化语句是:
// 获取登录的用户的名字
private void GetLandedName() {
db = helper.getWritableDatabase();
cursor = db.query("student", null, null, null, null, null, null);
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
if (cursor.getString(cursor.getColumnIndex("student_account"))
.equals(str_bundleAccount)) {
mainUserName = cursor.getString(cursor
.getColumnIndex("student_name"));
}
}
cursor.close();
db.close();
helper.close();
}
其中,“student”是建立的一个表,我的数据库中唯一一个4列的表:
db.execSQL("create table student(type varchar(20), student_name varchar(20), student_account varchar(20),"
+ "student_password varchar(20))");
在模拟器上可顺利运行,用我的手机S4就不能运行。
哪位大神知道原因,赶紧不尽。