I have read the previous posts on this already and none have provided a working solution (restarting emulator, commas, spacing tweaks).
Creating a simple SQLite database, but receiving the same error each time I run it;
05-12 04:06:17.541 2063-2063/com.disclosure_scots.disclosure_scots E/SQLiteLog﹕ (1) table login has no column named tel_no
05-12 04:06:17.542 2063-2063/com.disclosure_scots.disclosure_scots E/SQLiteDatabase﹕ Error inserting email=test@email.com name=test name tel_no=1231234123 created_at=2015-05-12 06:06:19 uid=55517c3b97a8b8.60336236
android.database.sqlite.SQLiteException: table login has no column named tel_no (code 1): , while compiling: INSERT INTO login(email,name,tel_no,created_at,uid) VALUES (?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
at com.disclosure_scots.disclosure_scots.SQLiteHandler.addUser(SQLiteHandler.java:85)
at com.disclosure_scots.disclosure_scots.RegisterActivity$2.onResponse(RegisterActivity.java:151)
at com.disclosure_scots.disclosure_scots.RegisterActivity$2.onResponse(RegisterActivity.java:128)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
My code, I have tried this with different spacing to no avail;
// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";
private static final String KEY_TEL_NO = "tel_no";
public SQLiteHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
+ KEY_ID + " INTEGER PRIMARY KEY, "
+ KEY_NAME + " TEXT, "
+ KEY_EMAIL + " TEXT UNIQUE, "
+ KEY_UID + " TEXT, "
+ KEY_CREATED_AT + " TEXT, "
+ KEY_TEL_NO + " TEXT " + ")";
db.execSQL(CREATE_LOGIN_TABLE);
Log.d(TAG, "Database tables created");
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);
// Create tables again
onCreate(db);
}
Am I missing something obvious?