这个问题已经被问过了,但我找不到类似的问题。
我必须上课:
public class Categorie {
// Attributs
private int identifiant;
private String libelle;
...
}
和
public class Restaurant {
// Attributs
private int identifiant;
private String nom;
private String description;
private List<Categorie> lesCategories;
...
}
但是对于SQLite,我不知道你如何使用 " lesCategories
"..
我用法语阅读了本教程:
在 SQLite 中,该对象type
不存在.. 只有String, Integer, Real, Blob.
更明确地说:我的光标有问题,它在这里 --> “????”:
因为,它不是 String 或 Int,而是对象..
public Restaurant ConvertCursorToObject(Cursor c) {
Restaurant restaurant= new Restaurant (
c.getInt(EnseigneOpenHelper.NUM_RES_ID),
c.getString(EnseigneOpenHelper.NUM_RES_NOM),
c.getString(EnseigneOpenHelper.NUM_RES_DESCRIPtion),
????
);
return restaurant;
}
/** * 转换 Restaurant 中的光标 */
public Restaurant ConvertCursorToOneObject(Cursor c) {
c.moveToFirst();
Restaurant restaurant = ConvertCursorToObject(c);
c.close();
return restaurant ;
}