The question is simple and to put it in just one line : ” The insert() function of SQLiteDatabase for Android tries to add the values in a random way “.
Meaning :
// Database creation sql statement
private static final String DATABASE_CREATE = "create table "
+ TABLE_NAME
+"( "
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_LATITUDE + "integer,"
+ COLUMN_LONGTITUDE + "integer,"
+ COLUMN_TITLE + "text,"
+ COLUMN_TEXT + " text not null"
+ ");";
And when i put the values and try to insert them :
values.put(COLUMN_ID, marker.getId() );
values.put(COLUMN_LATITUDE, marker.getLatitude() ); // lat
values.put(COLUMN_LONGTITUDE, marker.getLongtitude() ); // long
values.put(COLUMN_TITLE, marker.getTitle() ); // Title
values.put(COLUMN_TEXT, marker.getText() ); // Text
// Inserting Row
db.insert(TABLE_NAME, null, values);
but the error i got is :
E/Database(2542): android.database.sqlite.SQLiteException: table Items has no column named longtitude: , while compiling: INSERT INTO items(longtitude, text, title, latitude, _id) VALUES(?, ?, ?, ?, ?);
so i guess is tries to put the longtitude where the Id is and that causes the Error.
Is my assumption right? What do i need to change?
You have an error in your create Table statement, you’re missing some spaces before the types (integer,text), here’s the correct version:
Before you didn’t create a column named “longitude”. Instead “longitudeinteger” was created