Sqlite Docs
Sqlite Docs
NOT NULL, date TEXT NOT NULL, amount REAL NOT NULL, categoryId INTEGER,
categoryName TEXT NOT NULL, is_deleted INTEGER DEFAULT 0);
// Common Column
private static final String COLUMN_IS_DELETED = "is_deleted";
db.execSQL(CREATE_TABLE_EXPENSE);
db.execSQL(CREATE_TABLE_CATEGORY);
expense.setName(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_EXPENSE
_NAME)));
expense.setDate(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_EXPENSE
_DATE)));
expense.setId(cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_EXPENSE_ID))
);
expense.setAmount(cursor.getDouble(cursor.getColumnIndexOrThrow(COLUMN_EXPEN
SE_AMOUNT)));
expense.setCategoryId(cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_CATE
GORY_ID)));
expense.setCategoryName(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN
_CATEGORY_NAME)));
list.add(expense);
} while (cursor.moveToNext());
}
Log.d("mytag", "" + list.size());
return list;
}
category.setName(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_CATEGO
RY_NAME)));
category.setId(cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_CATEGORY_ID
)));
list.add(category);
} while (cursor.moveToNext());
}
Log.d("mytag", "" + list.size());
return list;
}
https://developer.android.com/training/data-storage/sqlite