I am receiving an error when I am trying to insert data into a SQL DB. The error suggest that my uName column does not exist when its trying to insert data into that column. From my observation this column should be created. I may be missing something. another eye on this may be helpful.
LogCat:
01-23 20:20:15.532: E/Database(2322): Error inserting uName=xxxx wUrl=xxxxxxxx sName=xxxx pWord=xxxx
01-23 20:20:15.532: E/Database(2322): android.database.sqlite.SQLiteException: table infoTable has no column named uName: , while compiling: INSERT INTO infoTable(uName, wUrl, sName, pWord) VALUES(?, ?, ?, ?);
DB Creation:
String sqlDataStore = "create table if not exists " +
TABLE_NAME_INFOTABLE + " ("+ BaseColumns._ID + " integer primary key autoincrement,"
+ COLUMN_NAME_SITE + "text not null,"
+ COLUMN_NAME_ADDRESS + "text not null,"
+ COLUMN_NAME_USERNAME + "text not null,"
+ COLUMN_NAME_PASSWORD + "text not null)";
db.execSQL(sqlDataStore);
Here is my class:
public class dataStore extends SQLiteOpenHelper {
//Table attributes
public static final String DATABASE_NAME = "SiteLogindb";
public static final int DATABASE_VERSION = 1;
public static final String TABLE_NAME_INFOTABLE = "infoTable";
// Data attributes
public static final String COLUMN_NAME_SITE = "sName";
public static final String COLUMN_NAME_ADDRESS = "wUrl";
public static final String COLUMN_NAME_USERNAME = "uName";
public static final String COLUMN_NAME_PASSWORD = "pWord";
public dataStore(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
// TODO Auto-generated constructor stub
}
issue was resolved by deleting database from emulator.
Go to DDMS then go to file explorer then open data–>—>data–> then your package —> then database and here you have your database and you can delete it by clicking minus “-” sign from top right.