【发布时间】:2018-02-10 20:13:56
【问题描述】:
在我从包含数组的数据库中获取内容的函数中,我找不到获取数组的方法:
public Meals getMeals(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(
TABLE_MEALS,
new String[]{KEY_ID, KEY_TITLE, KEY_DESC, KEY_CTRGRY, KEY_PIC, KEY_INGRDNTS}, KEY_ID + "=?",
new String[]{String.valueOf(id)}, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Meals Meal = new Meals(Integer.parseInt(cursor.getString(0)),
cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getInt(4), cursor./**placeholder for equivilant of getInt/String but for List<String>*/);
// return Meals
return Meal;
}
【问题讨论】:
-
public List<Meal> getMeals(int id)然后返回对象 Meal 列表
标签: android arrays database sqlite android-database