0

在这里我有一个错误,当我尝试在 android 中创建 sqlite 时,应用程序将在启动应用程序期间强制执行。当我删除创建数据库的代码时,应用程序可以运行。所以我想,我的数据库助手类可能有问题。有人知道我的错误吗???嗬[e有人可以帮忙。谢谢..

DBAdapater.java

    SQLiteDatabase mDb;
DBHelper mDbHelper;

public DBAdapter(Context context){
    //this.mCtx = context;
    //mDbHelper = new DBHelper(mCtx);
    mDbHelper = new DBHelper(context);
    mDb = mDbHelper.getWritableDatabase();
}

public void close(){
    mDbHelper.close();
    }

DBHelper.java

    public DBHelper(Context context) {
    super(context, "medical", null, 1);
    }

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE  (" +
            "Staff_ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
            "Staff_Name TEXT NOT NULL," +
            "Password TEXT NOT NULL," +
            "Staff_Acid TEXT NOT NULL," +
            "Ward_Name TEXT NOT NULL);");
    }

@Override
public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {
    db.execSQL("DROP TABLE IF EXISTS members");
    onCreate(db);
    }

我的活动课

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
//code for create sqlite
dbAdapter = new DBAdapter(PatientMedicalRecordActivity.this);

}
4

0 回答 0