SQLite error an android: foreign key mismatch on Insert on Database
and thanks in advance!
I'm going crazy with an error, when trying to insert in a table that has foreign keys. Values exist, are the same type and are not-null... And the more funny is that first time fails, and only first! The other inserts works perfectly!
I've tried to delete insert and repeat, and the error is not throwed again... Only first time!
I'm trying it on Android 2.2 (Froyo), and before was in 2.1 with no foreign keys.

Sorry for the big "message" but i'm lost!


error:
__________________________________________


    03-30 16:59:56.333: E/AndroidRuntime(28007): android.database.sqlite.SQLiteException: foreign key mismatch: , while compiling: INSERT INTO productoslista(idProducto, idUnidad, comprado, idLista, comentario, cantidad) VALUES(?, ?, ?, ?, ?, ?);
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1432)

tables:
_________________________

    CREATE TABLE [ProductosLista] (
    [idLista] INTEGER  NOT NULL,
    [idProducto] INTEGER  NOT NULL,
    [cantidad] INTEGER  NOT NULL,
    [idUnidad] INTEGER  NOT NULL,
    [comprado] INTEGER  NOT NULL,
    [comentario] TEXT,
    PRIMARY KEY ([idLista],[idProducto],[comentario]),
    FOREIGN KEY (idLista) REFERENCES Listas(idLista),
    FOREIGN KEY (idProducto) REFERENCES Productos(idProducto),
    FOREIGN KEY (idUnidad) REFERENCES Unidades(idUnidad)
    
    
    
    CREATE TABLE [Listas] (
    [idLista] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
    [descripcion] TEXT  UNIQUE NOT NULL,
    [fechaCreacion] INTEGER  NOT NULL,
    [visible] TEXT  NOT NULL,
    [estadoCompra] INTEGER NOT NULL
    );
    
    CREATE TABLE [Unidades] (
    [idUnidad] INTEGER  NOT NULL,
    [idIdioma] INTEGER  NOT NULL,
    [abreviatura] TEXT  NOT NULL,
    [descripcion] TEXT  NOT NULL,
    --PRIMARY KEY ([idUnidad],[idIdioma]),
    FOREIGN KEY (idIdioma) REFERENCES Idiomas(idIdioma)
    );
    
    CREATE TABLE [Productos] (
    [idProducto] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
    [idPadre] INTEGER  NOT NULL,
    [idCategoria] INTEGER  NOT NULL,
    [idTipoAlimentacion] INTEGER NOT NULL,
    [eliminado] INTEGER NOT NULL,
    [imagen] INTEGER,
    FOREIGN KEY (idPadre) REFERENCES Productos(idProducto),
    FOREIGN KEY (idCategoria) REFERENCES Categorias(idCategoria)
    );


SQLite error an android: foreign key mismatch on Insert on Database
===

and thanks in advance!
I'm going crazy with an error, when trying to insert in a table that has foreign keys. Values exist, are the same type and are not-null... And the more funny is that first time fails, and only first! The other inserts works perfectly!
I've tried to delete insert and repeat, and the error is not throwed again... Only first time!
I'm trying it on Android 2.2 (Froyo), and before was in 2.1 with no foreign keys.

Sorry for the big "message" but i'm lost!


error:
__________________________________________


    03-30 16:59:56.333: E/AndroidRuntime(28007): android.database.sqlite.SQLiteException: foreign key mismatch: , while compiling: INSERT INTO productoslista(idProducto, idUnidad, comprado, idLista, comentario, cantidad) VALUES(?, ?, ?, ?, ?, ?);
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
    03-30 16:59:56.333: E/AndroidRuntime(28007): 	at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1432)

tables:
_________________________

    CREATE TABLE [ProductosLista] (
    [idLista] INTEGER  NOT NULL,
    [idProducto] INTEGER  NOT NULL,
    [cantidad] INTEGER  NOT NULL,
    [idUnidad] INTEGER  NOT NULL,
    [comprado] INTEGER  NOT NULL,
    [comentario] TEXT,
    PRIMARY KEY ([idLista],[idProducto],[comentario]),
    FOREIGN KEY (idLista) REFERENCES Listas(idLista),
    FOREIGN KEY (idProducto) REFERENCES Productos(idProducto),
    FOREIGN KEY (idUnidad) REFERENCES Unidades(idUnidad)
    
    
    
    CREATE TABLE [Listas] (
    [idLista] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
    [descripcion] TEXT  UNIQUE NOT NULL,
    [fechaCreacion] INTEGER  NOT NULL,
    [visible] TEXT  NOT NULL,
    [estadoCompra] INTEGER NOT NULL
    );
    
    CREATE TABLE [Unidades] (
    [idUnidad] INTEGER  NOT NULL,
    [idIdioma] INTEGER  NOT NULL,
    [abreviatura] TEXT  NOT NULL,
    [descripcion] TEXT  NOT NULL,
    --PRIMARY KEY ([idUnidad],[idIdioma]),
    FOREIGN KEY (idIdioma) REFERENCES Idiomas(idIdioma)
    );
    
    CREATE TABLE [Productos] (
    [idProducto] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
    [idPadre] INTEGER  NOT NULL,
    [idCategoria] INTEGER  NOT NULL,
    [idTipoAlimentacion] INTEGER NOT NULL,
    [eliminado] INTEGER NOT NULL,
    [imagen] INTEGER,
    FOREIGN KEY (idPadre) REFERENCES Productos(idProducto),
    FOREIGN KEY (idCategoria) REFERENCES Categorias(idCategoria)
    );

