Я использую SQLiteOpenHelper
в своем проекте, и когда я использую метод add_leader, все работает, но когда я использую метод add_Person, он возвращает false.Это второй экземпляр sqlite.
Я использую Manjaro 18 Linux
Любая помощь, пожалуйста?
public class SqliteHelper extends SQLiteOpenHelper {
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE " + START+ "("+KIND+" text) ");
sqLiteDatabase.execSQL("CREATE TABLE " + PERRSON + "("+ID_PER+" INTEGER PRIMARY KEY AUTOINCREMENT ,"
+FULLNAME_PER+" text,"+BIRTH_DAY_PER+"text," +BIRTH_MONTH_PER+" text,"+BIRTH_YEAR_PER+" text,"
+LEVEL_EDUCATION+" text,"+MOY_ONE+" text,"+MOY_TWO+" text,"+MOY_THREE+"text) ");
sqLiteDatabase.execSQL("CREATE TABLE " + LEADER + "("+ID_LEADER+" INTEGER PRIMARY KEY AUTOINCREMENT ,"+FULLNAME_LDR+" text,"+
BIRTH_DAY_LDR+" text,"+BIRTH_MONTH_LDR+" text,"+BIRTH_YEAR_LDR+" text) ");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL(" DROP TABLE IF EXISTS " + START);
sqLiteDatabase.execSQL(" DROP TABLE IF EXISTS " + PERRSON);
sqLiteDatabase.execSQL(" DROP TABLE IF EXISTS " + LEADER);
onCreate(sqLiteDatabase);
}
public boolean add_Person(String name, String date_day, String date_month, String date_year,
String level,String moy1,String moy2,String moy3) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(FULLNAME_PER, name);
cv.put(BIRTH_DAY_PER, date_day);
cv.put(BIRTH_MONTH_PER, date_month);
cv.put(BIRTH_YEAR_PER, date_year);
cv.put(LEVEL_EDUCATION, level);
cv.put(MOY_ONE, moy1);
cv.put(MOY_TWO, moy2);
cv.put(MOY_THREE, moy3);
long results = db.insert(PERRSON, null, cv);
db.close();
if (results == -1) return false;
else return true;
}
public boolean add_leader(String fullname, String date_day, String date_month, String date_year) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(FULLNAME_LDR, fullname);
cv.put(BIRTH_DAY_LDR, date_day);
cv.put(BIRTH_MONTH_LDR, date_month);
cv.put(BIRTH_YEAR_LDR, date_year);
long results = db.insert(LEADER, null, cv);
db.close();
if (results == -1) return false;
else return true;
}