0

我正在尝试制作一个简单的登录注册系统,我从 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});

G

当我注册帐户时,我的应用程序崩溃了。我正在使用 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;
4

1 回答 1

0

没有这样的栏目:电子邮件

这意味着您的列在您的表中不存在。如果您稍后添加了它,请卸载该应用程序,或增加数据库架构。

于 2019-05-03T12:19:18.443 回答