Я создал несколько таблиц в sql, как показано другим разработчиком, и после того, как я попытался зарегистрировать пользователя, приложение, к сожалению, остановилось. Вот некоторый код в databasehelper
, это таблицы открытого классасоздать метод вставки для вставки данных в публичную логическую вставку базы данных (String FirstName, String SecondName, String Email, String Password) {
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
//create content values
ContentValues values1 = new ContentValues();
values1.put("FirstName", FirstName);
values1.put("SecondName", SecondName);
values1.put("Email", Email);
values1.put("Password", Password);
//insert into database table
sqLiteDatabase.insert(TABLE_USERS1, null, values1);
return true;
}
public boolean insert2 (String FullName, String StudentNumber, String Course, String Level) {
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
//create content values
ContentValues values2 = new ContentValues();
values2.put("FullName", FullName);
values2.put("StudentNumber", StudentNumber);
values2.put("Course", Course);
values2.put("Level", Level);
//insert into database table
sqLiteDatabase.insert(TABLE_USERS2, null, values2);
return true;
}
public boolean insert3 (String Cand_Name, String Counts){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
//create content values for categories
ContentValues values3 = new ContentValues();
values3.put("Cand_Name", Cand_Name);
values3.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY1, null, values3);
//create content values for categories
ContentValues values4 = new ContentValues();
values4.put("Cand_Name", Cand_Name);
values4.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY2, null, values4);
//create content values for categories
ContentValues values5 = new ContentValues();
values5.put("Cand_Name", Cand_Name);
values5.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY3, null, values5);
//create content values for categories
ContentValues values6 = new ContentValues();
values6.put("Cand_Name", Cand_Name);
values6.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY4, null, values6);
//create content values for categories
ContentValues values7 = new ContentValues();
values7.put("Cand_Name", Cand_Name);
values7.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY5, null, values7);
//create content values for categories
ContentValues values8 = new ContentValues();
values8.put("Cand_Name", Cand_Name);
values8.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY6, null, values8);
//create content values for categories
ContentValues values9 = new ContentValues();
values9.put("Cand_Name", Cand_Name);
values9.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY7, null, values9);
//create content values for categories
ContentValues values10 = new ContentValues();
values10.put("Cand_Name", Cand_Name);
values10.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY8, null, values10);
//create content values for categories
ContentValues values11 = new ContentValues();
values11.put("Cand_Name", Cand_Name);
values11.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY9, null, values11);
//create content values for categories
ContentValues values12 = new ContentValues();
values12.put("Cand_Name", Cand_Name);
values12.put("Counts", Counts);
//insert into categories tables
sqLiteDatabase.insert(TABLE_CATEGORY10, null, values12);
return true;
}
//checking if the email existing
public Boolean chkemail (String Email){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from Admin where Email=?", new String[]{Email});
if (cursor.getCount()>0) return false;
else return true;
}
//checking if the Student number existing
public Boolean chkStudentNo (String StudentNumber){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from Student where StudentNumber=?", new String[]{StudentNumber});
if (cursor.getCount()>0) return false;
else return true;
}
}