I have this database structure:
protected static final String Buildings =
"CREATE TABLE "
+ Building.BUILDING_TAG + " ( "
+ Building.ID + " LONG PRIMARY KEY, "
+ Building.NOME + " TEXT,"
+ Building.POSIZIONE + " TEXT, "
+ Building.DESCRIZIONE + " TEXT, "
+ Building.DATA_C + " LONG, "
+ Building.DATA_U + " LONG, "
+ Building.LINK + " TEXT, "
+ Building.NUMERO_DI_PIANI + " INTEGER NOT NULL, "
+ Building.VERSIONE + " INTEGER, "
+ Building.FOTO + " TEXT, "
+ Building.GEOMETRIA + " TEXT "
+");";
And I’m trying to insert this data:
id=6
descrizione=nel mezzo del cammin di nostra vita
data_creazione=1353904373000
geometria=[[46074778,13234062],[46074778,13235521],[46073945,13235521],[46073885,13233976],[46074778,13234062],]
versione=1
link=http://www.caso.com/
nome=erferf
foto=
posizione=[46074332,13234748]
data_update=1355731095000
Every time I delete the database from the simulator, and, in the code, I try to delete an eventual building with the same id.
Here is the error:
E/Database(16622): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
E/Database(16622): at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
E/Database(16622): at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
E/Database(16622): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1582)
E/Database(16622): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
Can you help me?
I was looking left when the error was at right.
I forgot to save also the field numero_di_piani
So stupid!