mardi 11 août 2015

Foreign Key Android Not Working

categories(id, name, slug);
places(id, name, cat_id(foreignKey));

When I query the table using

String where = "cat_id = ?";
String[] whereArgs = new String[]{"1488764085"}; 
c = db.query("places", new String[]{"name", "cat_id"}, where, whereArgs, null, null, null);

The returned Cursor is having items but when I append another field in the where clause like below the Cursor returns the count -1

String where = "name = ? AND cat_id = ?";
String[] whereArgs = new String[]{"xxx", "1488764085"}; 
c = db.query("places", new String[]{"name", "cat_id"}, where, whereArgs, null, null, null);

Can any one point out the actual issue why it is happening so

Note : The place table is having a field with value "xxx".

Aucun commentaire:

Enregistrer un commentaire