SQLite Forum

Foreign key trust error
Login

Foreign key trust error

(1) By yuri (yurizaki26) on 2020-06-23 15:07:31 [link] [source]

When I execute a project and send a record of a Forenkay where this key does not exist, the database is saving normally, already using the software "SQLiteStudio" it does not allow to be inserted.

When I try to save I would have to show an error.

I'm using android studio, with java.

(2) By Dan Kennedy (dan) on 2020-06-23 17:31:17 in reply to 1 [source]

You might need to enable FK support using:

PRAGMA foreign_keys = ON;

https://www.sqlite.org/foreignkeys.html#fk_enable

You need to execute this PRAGMA immediately after opening each connection. Or from within the onConfigure() hook if using SQLiteOpenHelper.

https://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper#onConfigure(android.database.sqlite.SQLiteDatabase%29