TABLE_BLOCKED_SMS , TABLE_BLOCK_LIST I have two tables which structure you can display in pictures. I made this table with below sqlite statements. The problem is when i add some data the foreign key named(fk_id_block_list) in TABLE_BLOCKED_SMS shown no any data but it should show ids of id_block_list column from TABLE_BLOCK_LIST. kindly help.
TABLE_BLOCKED_SMS
public static final String CREATE_TABLE_BLOCKED_SMS = "CREATE TABLE " + TABLE_BLOCKED_SMS
+ "(" + ID_BLOCKED_SMS + " INTEGER PRIMARY KEY AUTOINCREMENT DEFAULT 0, "
+ MESSAGE_BODY + " TEXT,"
+ FK_ID_BLOCK_LIST + " INTEGER," +
"FOREIGN KEY(" + FK_ID_BLOCK_LIST + ") REFERENCES " + TABLE_BLOCK_LIST + "(" + ID_BLOCK_LIST +"))";
TABLE_BLOCK_LIST:
public static final String CREATE_TABLE_BLOCK_LIST = "CREATE TABLE " + TABLE_BLOCK_LIST
+ "(" + ID_BLOCK_LIST + " INTEGER PRIMARY KEY AUTOINCREMENT DEFAULT 0,"
+ ORIGINATING_ADDRESS + " TEXT)";
insert code:
public boolean insertToBlockList(String originatingAddress,String messageBody){
try {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues value_TABLE_BLOCK_LIST = new ContentValues();
ContentValues value_TABLE_BLOCKED_SMS = new ContentValues();
value_TABLE_BLOCK_LIST.put(ORIGINATING_ADDRESS, originatingAddress);
db.insert(TABLE_BLOCK_LIST, null, value_TABLE_BLOCK_LIST);
value_TABLE_BLOCKED_SMS.put(MESSAGE_BODY, messageBody);
db.insert(TABLE_BLOCKED_SMS, null, value_TABLE_BLOCKED_SMS);
} catch (Exception e) {
Log.d("Insertion to Block list", " error is" + e.getMessage());
}
return true;
}
Aucun commentaire:
Enregistrer un commentaire