I am having a registration form builted into my app in which user fills some information and those information are stored into SQLLite Database. I have all the columns created and still it gives me an Error of non-existing column.
My Database Adapter:
public class DatabaseAdapter {
static final String DATABASE_NAME = "login.db";
static final int DATABASE_VERSION = 1;
static final int NAME_COLUMN = 1;
public static final String DATABASE_CREATE = "create table "+"LOGIN"+
"( " +"ID"+" integer primary key autoincrement,"+ "USERNAME text, PASSWORD text, DATE_KATATAKSIS text, DATE_APOLUSIS text, SEIRA int, ESSO text, DUNAMI text, OPLO text); ";
public SQLiteDatabase db;
private final Context context;
private DataBaseHelper dbHelper;
public DatabaseAdapter(Context _context){
context = _context;
dbHelper = new DataBaseHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public DatabaseAdapter open() throws SQLException {
db = dbHelper.getWritableDatabase();
return this;
}
public void close(){
db.close();
}
public SQLiteDatabase getDatabaseInstance(){
return db;
}
public void insertEntry(String userName,String password, String dateKatataksis, String dateApolusis, String seira, String esso, String enopliDunami, String oplo){
ContentValues newValues = new ContentValues();
newValues.put("USERNAME",userName);
newValues.put("PASSWORD",password);
newValues.put("DATE_KATATAKSIS",dateKatataksis);
newValues.put("DATE_APOLUSIS",dateApolusis);
newValues.put("SEIRA",seira);
newValues.put("ESSO",esso);
newValues.put("DUNAMI",enopliDunami);
newValues.put("OPLO",oplo);
db.insert("LOGIN", null, newValues);
}
public int deleteEntry(String UserName){
String where="USERNAME=?";
int numberOFEntriesDeleted= db.delete("LOGIN", where, new String[]{UserName}) ;
return numberOFEntriesDeleted;
}
public String getSinlgeEntry(String userName){
Cursor cursor=db.query("LOGIN", null, " USERNAME=?", new String[]{userName}, null, null, null);
if(cursor.getCount()<1)
{
cursor.close();
String msg = "User not found";
return msg;
}
cursor.moveToFirst();
String password= cursor.getString(cursor.getColumnIndex("PASSWORD"));
cursor.close();
return password;
}
public void updateEntry(String userName, String password, String dateKatataksis, String dateApolusis, String seira, String esso, String enopliDunami, String oplo){
ContentValues updatedValues = new ContentValues();
updatedValues.put("USERNAME", userName);
updatedValues.put("PASSWORD",password);
updatedValues.put("DATE_KATATAKSIS",dateKatataksis);
updatedValues.put("DATE_APOLUSIS",dateApolusis);
updatedValues.put("SEIRA",seira);
updatedValues.put("ESSO",esso);
updatedValues.put("DUNAMI",enopliDunami);
updatedValues.put("OPLO",oplo);
String where="USERNAME = ?";
db.update("LOGIN",updatedValues, where, new String[]{userName});
}
}
and the Error:
08-24 16:15:10.057 11238-11238/com.project.matrix.lelemetroga E/SQLiteLog﹕ (1) table LOGIN has no column named ESSO
08-24 16:15:10.057 11238-11238/com.project.matrix.lelemetroga E/SQLiteDatabase﹕ Error inserting DATE_KATATAKSIS=2/7/2015 USERNAME=xcvz DATE_APOLUSIS=18/7/2015 ESSO=F OPLO= PASSWORD=xcvzxcv DUNAMI=Πολεμική Αεροπορία SEIRA=234
android.database.sqlite.SQLiteException: table LOGIN has no column named ESSO (code 1): , while compiling: INSERT INTO LOGIN(DATE_KATATAKSIS,USERNAME,DATE_APOLUSIS,ESSO,OPLO,PASSWORD,DUNAMI,SEIRA) VALUES (?,?,?,?,?,?,?,?)
Where the column ESSO is:
public static final String DATABASE_CREATE = "create table "+"LOGIN"+
"( " +"ID"+" integer primary key autoincrement,"+ "USERNAME text, PASSWORD text, DATE_KATATAKSIS text, DATE_APOLUSIS text, SEIRA int, ***ESSO text***, DUNAMI text, OPLO text); ";
Anyone would like to point out what the mistake is? Thanks in Advance!!!
Aucun commentaire:
Enregistrer un commentaire