0

In a previous post, I have not been clear enough about my problem:

I have 2 class :

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;

    ...
}

And in 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)
);

But for create my cursor, i don't know how do it...

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 ; 
}

This problem it's here = "????" My constructor want an object of type List Categorie.

1 Answer 1

1

Perform another query for the categories using the restaurant id you acquired from the first query. Then just build a list of categories from the results of the new cursor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.