Android Studio登录系统数据库问题

时间:2019-05-03 12:11:21

标签: java android android-sqlite login-system

我正在尝试制作一个简单的登录注册系统,并且观看了youtube上的视频,因此出现了这个问题。

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

这是出问题的地方

    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;

g

我注册一个帐户后,我的应用程序崩溃了。 我正在使用sqlite。

这是数据库帮助程序代码

{{1}}

1 个答案:

答案 0 :(得分:0)

  

没有这样的列:电子邮件

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