I have encounter some difficulties saving my data after i added new column to my sqlite. e.g the column_contact_grp in the example below
in my contract class:
public final static String _ID = BaseColumns._ID;
public final static String COLUMN_CONTACT_NAME = "name";
public final static String COLUMN_CONTACT_NUMBER = "number";
public final static String COLUMN_CONTACT_GRP = "group";
in my Dbhelper class:
@Override
public void onCreate(SQLiteDatabase db) {
// Create a String that contains the SQL statement to create the pets table
String SQL_CREATE_CONTACTS_TABLE = "CREATE TABLE " + NameEntry.TABLE_NAME + " ("
+ NameEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NameEntry.COLUMN_CONTACT_NAME + " TEXT NOT NULL, "
+ NameEntry.COLUMN_CONTACT_NUMBER + " TEXT,"
+ NameEntry.COLUMN_CONTACT_GRP + " TEXT );";
// Execute the SQL statement
db.execSQL(SQL_CREATE_CONTACTS_TABLE);
}
in my Main Activity:
ContentValues values = new ContentValues();
values.put(NameEntry.COLUMN_CONTACT_NAME, "Name");
values.put(NameEntry.COLUMN_CONTACT_NUMBER, "1234");
values.put(NameEntry.COLUMN_CONTACT_GRP, "testing");
The program "used to work and save well" but it fail saving when i added a new data. When i remove the additional code (COLUMN_CONTACT_GRP related codes), it will work again, able to save and display name and number correctly on my listview. Anyone can guide where should i look out for the errors?