So my SQLite
INSERT INTO
function is inserting data in the wrong order even though I have put the contentValues
in the right order.
This is my class:
public class UserInfo extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 2;
private static final String DB_TABLE_NAME = "usersData";
private static final String USERNAME = "username";
private static final String DETAILS = "details";
public static final String DATABASE_NAME = "users.db";
private static final String DICTIONARY_TABLE_CREATE =
"CREATE TABLE " + DB_TABLE_NAME + " (" +
USERNAME + " TEXT," + DB_ONE + " TEXT" + " )";
public ReminderDB(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
Log.d("Database operations", "Database created");
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DICTIONARY_TABLE_CREATE);
Log.d("Database operations", "Table created");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE_NAME );
onCreate(db);
}
public void addReminder(String username, String reminders){
SQLiteDatabase sqLiteDatabase = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(USERNAME, username);
contentValues.put(DETAILS, details);
sqLiteDatabase.insert(DB_TABLE_NAME, null, contentValues);
}
}
LogCat
error stack:
android.database.sqlite.SQLiteException: table userData has no column named username (code 1): , while compiling: INSERT INTO userData(details,username) VALUES (?,?)