Android Studio login system database problem

115 Views Asked by At

I am trying to make a simple login registration system and I watch a video from youtube and this problem come up.

        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;

this is the line where thing goes wrong

Cursor cursor = db.rawQuery("Select * from user where email=?", new String[]{email});

g

my app went crashed when i register an account. im using sqlite.

this is the database helper code

    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;
1

There are 1 best solutions below

0
coroutineDispatcher On

no such column: email

This means your column doesn't exist in your table. If you have added it later , please uninstall the app , or increment the database schema .