title: SQlite-Foreign key
body: <p>hello i'm a beginner in sqlite in android i made a 2 tables database and i'm trying to make a foreing key in the second table which is the id of the first table here is the code and i would appreciate if you tell me if there is other errors in the code espiciallly in the queries thank you in advance</p>
  
  <pre><code>package com.example.hp.memorybackup;
  
  import android.content.Context;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  import java.sql.SQLException;
  
  /**
   * Created by hp on 13/04/2015.
   */
  public class SanaHelper extends SQLiteOpenHelper {
      private static final String DATABASE_NAME = "memorydatabase";
          private static final String TABLE_NOTE_NAME = "NOTETABLE";
      private static final int DATABASE_VERSION = 1;
      private static final String UID_NOTE = "_idnote";
      private static final String TITRE = "Titre";
      private static final String OBJET = "Objet";
      private static final String PRAM_N = "Prametres_note";
      private static final String CREATE_NOTE = "CREATE TABLE" + TABLE_NOTE_NAME + "(" + UID_NOTE + " INTEGER PRIMARY KEY AUTOINCREMENT," + TITRE + " VARCHAR (255)" + OBJET + "VARCHAR (255)" + PRAM_N + "VARCHAR (255) ;";
          private static final String TABLE_USER_NAME = "USERTABLE";
      private static final String UID_USER = "_iduser";
      private static final String NOM = "Nom";
      private static final String PRENOM = "Prenom";
      private static final String DATE_NAISS="Date_Naiss";
      private static final String E_MAIL = "E-mail";
      private static final String LOGIN = "Login";
      private static final String MOT_PASSE = "Mot-passe";
      private static final String CREATE_USER = "CREATE TABLE" + TABLE_USER_NAME + "(" +  UID_USER + " INTEGER PRIMARY KEY AUTOINCREMENT," + NOM + " VARCHAR (255)" + PRENOM + "VARCHAR (255)" + DATE_NAISS + "DATE "
              + LOGIN + " VARCHAR (255) "+MOT_PASSE+" VARCHAR (255);";
  
  
  
  
  
      private Context context;
  
      public SanaHelper(Context context) {
          super(context, "DATABASE_NAME", null, 1);
          this.context = context;
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
  
          try {
              db.execSQL(CREATE_NOTE);
              db.execSQL(CREATE_USER);
          } catch (android.database.SQLException e) {
              e.printStackTrace();
          }
  
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          onCreate(db);
      }
  }
  </code></pre>