I know this question gets asked a lot and I have looked through all the answers and cant seem to fix the error. I am just trying to do a simple select all from one of my tables but I am getting an error saying no such table ingredient (code 1)
. I have used the same syntax in the create statement as two other tables that I know work so I dont know where I have gone wrong.
Any guidance will be greate
Create Statement
//Ingredient create statement
private static final String CREATE_TABLE_INGREDIENTS = "CREATE TABLE "
+ INGREDIENTS_TABLE + "("
+ KEY_ID + " INTEGER PRIMARY KEY AUTO INCREMENT,"
+ KEY_RECIPE_CODE + " INTEGER AUTO INCREMENT, "
+ KEY_INGREDIENT_NAME + " TEXT,"
+ " FOREIGN KEY ("+KEY_RECIPE_CODE+") REFERENCES " +RECIPE_TABLE+"("+KEY_CODE+"));";
Ingredient Column Names
//Ingredient column names
public static final String KEY_RECIPE_CODE ="reciep_code";
public static final String KEY_INGREDIENT_NAME ="ingredient_name";
public static final String KEY_MEASUREMENT = "measurement";
Select all function
public Cursor possibleRecipes()
{
return db.query(INGREDIENTS_TABLE, new String[]{KEY_ID, KEY_CONTENTS_NAME}, null, null, null, null, null);
}
Calling the function from the class
Cursor cursor = adapter.possibleRecipes();