在之前的帖子中,我对我的问题还不够清楚:
我有 2 节课:
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 中:
CREATE TABLE Categorie
( categorie_id INTEGER PRIMARY KEY
, libelle TEXT NOT NULL
);
CREATE TABLE Restaurant
( restaurant_id INTEGER PRIMARY KEY
, nom TEXT NOT NULL
, description TEXT
);
CREATE TABLE RestaurantCategorie
( restaurant_id INTEGER NOT NULL REFERENCES Restaurant
, categorie_id INTEGER NOT NULL REFERENCES Categorie
, PRIMARY KEY (restaurant_id, categorie_id)
);
但是为了创建我的光标,我不知道该怎么做......
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;
}
/** * Convert a cursor in Restaurant */
public Restaurant ConvertCursorToOneObject(Cursor c) {
c.moveToFirst();
Restaurant restaurant = ConvertCursorToObject(c);
c.close();
return restaurant ;
}
这个问题就在这里=“??????” 我的构造函数想要一个 List Category 类型的对象。