Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 =

image text in transcribed 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); } 

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

Use good transitions

Answered: 1 week ago

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago