title: android.database.sqlite.SQLiteConstraintException: foreign key constraint failed (code 19)
body: <p>I've this code for creating my sqlLite DB in android application:</p>
  
  <pre><code>private static final String CREATE_TABELLA_PERSONE = "CREATE TABLE TB_PERSONE "
  + "(_ID integer,"
  + "CODICE_PERSONA text not null, DESC_PERSONA text null, "
  + "PRIMARY KEY (CODICE_PERSONA));";
  </code></pre>
  
  <p>and</p>
  
  <pre><code>private static final String CREATE_TABELLA_USCITE = "CREATE TABLE AN_USCITE "
  + "(_ID integer, "
  + "CODICE_USCITA text null, SCADENZA text null, DATA text null,"
  + "PERSONA text not null REFERENCES TB_PERSONE(CODICE_PERSONA) ON DELETE NO ACTION ON UPDATE      CASCADE,PRIMARY KEY(CODICE_USCITA));";
  </code></pre>
  
  <p>When i call the function for DELETE a row in "TB_PERSONE"</p>
  
  <pre><code>public int SQLdelete(String tabella, String id) {
      return database.delete(tabella, "_ID=" + id, null);
  }
  </code></pre>
  
  <p>the application show me this error:</p>
  
  <pre><code>04-27 11:15:27.152: E/AndroidRuntime(22031): FATAL EXCEPTION: main
  04-27 11:15:27.152: E/AndroidRuntime(22031): android.database.sqlite.SQLiteConstraintException:           
  foreign key constraint failed (code 19)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:727)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1494)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at it.jackpot21.personalmoney.DbAdapter.SQLdelete(DbAdapter.java:89)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at it.jackpot21.personalmoney.PersoneActivity$5.onClick(PersoneActivity.java:215)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.view.View.performClick(View.java:4084)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.view.View$PerformClick.run(View.java:16966)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.os.Handler.handleCallback(Handler.java:615)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.os.Handler.dispatchMessage(Handler.java:92)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.os.Looper.loop(Looper.java:137)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at android.app.ActivityThread.main(ActivityThread.java:4745)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at java.lang.reflect.Method.invoke(Method.java:511)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  04-27 11:15:27.152: E/AndroidRuntime(22031):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Can someone help me pls? <br>
  Thanks a lot! :)</p>
  
  <p>EDIT: <br>
  I solved it by putting <code>ON DELETE SET NULL</code>.<br>
  Thanks at all!</p>