I need to check to see if a column exists and if it doesn\'t exist add it. From my research it looks like sqlite doesn\'t support IF statements and case statement should be
I updated the function of a friend... tested and working now
public boolean isFieldExist(String tableName, String fieldName)
{
boolean isExist = false;
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("PRAGMA table_info(" + tableName + ")", null);
if (res.moveToFirst()) {
do {
int value = res.getColumnIndex("name");
if(value != -1 && res.getString(value).equals(fieldName))
{
isExist = true;
}
// Add book to books
} while (res.moveToNext());
}
return isExist;
}