Question: public static final int DATABASE_VERSION = 1; // Database Name public static final String DATABASE_NAME = LocalRugbyDB.db; //table names public static final String TABLE_PLAYER_INFO =

 public static final int DATABASE_VERSION = 1; // Database Name public public static final int DATABASE_VERSION = 1; // Database Name public static final String DATABASE_NAME = "LocalRugbyDB.db"; //table names public static final String TABLE_PLAYER_INFO = "PLAYER_Local"; public static final String TABLE_TEAM_INFO = "TEAM_local"; //add fields to player table public static final String KEY_PLAYER_ID = "_id"; public static final String KEY_FNAME = "first_name"; public static final String KEY_LNAME = "last_name"; public static final String KEY_AGE = "age"; public static final String KEY_HEIGHT = "height"; public static final String KEY_WEIGHT = "weight"; public static final String KEY_POSITION = "position"; public static final String KEY_TEAM = "team"; public static final String TEAM_ID = "team_id"; // add field to team table public static final String KEY_TEAM_ID = "_id"; public static final String KEY_TEAMNAME = "team_name"; public MySQLiteHelper(Context context, String name, CursorFactory factory, int version) { super(context, DATABASE_NAME, null, DATABASE_VERSION); Log.i("onCreateMaybe", "Created"); } @Override public void onCreate(SQLiteDatabase db) { // SQL statement to create book table String CREATE_PLAYER_TABLE = "CREATE TABLE " + TABLE_PLAYER_INFO + "( " + KEY_PLAYER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_FNAME + " TEXT," + KEY_LNAME + " TEXT," + KEY_POSITION + " TEXT," + KEY_HEIGHT + " TEXT," + KEY_AGE + " TEXT," + KEY_WEIGHT + " TEXT," + KEY_TEAM + " TEXT," + TEAM_ID + " integer," + " FOREIGN KEY ("+TEAM_ID+") REFERENCES "+TABLE_TEAM_INFO+" ("+KEY_TEAM_ID+"));"; String CREATE_TEAM_TABLE = "CREATE TABLE " + TABLE_TEAM_INFO + "( " + KEY_TEAM_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_TEAMNAME + " TEXT" + ");"; // create books table db.execSQL("PRAGMA foreign_keys = ON;"); db.execSQL(CREATE_TEAM_TABLE); db.execSQL(CREATE_PLAYER_TABLE); } 

static final String DATABASE_NAME = "LocalRugbyDB.db"; //table names public static final String

android sqlite foreign key not working i'm trying to create a relationship between 2 tables but the FK is not populating. it is remaining null. below is my code android sqlite foreign key not working i'm trying to create a relationship between 2 tables but the FK is not populating. it is remaining null. below is my code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!