我正在尝试制作一个简单的登录注册系统,我观看了 youtube 上的视频,然后出现了这个问题。
public Boolean chkmail(String email) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("Select * from user where email=?", new String[]{email});
if(cursor.getCount()>0) return false;
else return true;
这是出错的地方
Cursor cursor = db.rawQuery("Select * from user where email=?", new String[]{email});
当我注册帐户时,我的应用程序崩溃了。 我正在使用 sqlite。
这是数据库帮助程序代码
public DatabaseHelper(Context context) {
super(context, "Login.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("Create table user(email text primary key, password text)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("drop table if exists user");
}
public boolean insert(String email, String password) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("email", email);
contentValues.put("password", password);
long ins = db.insert("user", null, contentValues);
if(ins==-1) return false;
else return true;
最佳答案
no such column: email
这意味着您的表中不存在您的列。如果您稍后添加了它,请卸载该应用程序,或增加数据库架构。
关于java - Android Studio登录系统数据库问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55969536/