Reputation: 383
I'm creating a class called DBHelper to make easier to use dao inside my app but i dont know how to do a simple select they keep giving that "Getting starting" link but a I dont understand nothing, any help modifing these codes from the class to do a simple select?
"select * from SEGUIMENTO"
public class DBHelper {
static DaoSession daoSession;
static DaoMaster.DevOpenHelper daoMasterDevOpenHelper;
static DaoMaster daoMaster;
static SQLiteDatabase sqLiteDatabase;
Context context;
public DBHelper(Context context) {
this.context = context;
setupDatabase();
}
public void setupDatabase()
{
daoMasterDevOpenHelper = new DaoMaster.DevOpenHelper(context,"guest-db",null);
sqLiteDatabase = daoMasterDevOpenHelper.getWritableDatabase();
daoMaster = new DaoMaster(sqLiteDatabase);
daoSession = daoMaster.newSession();
}
}
Upvotes: 0
Views: 535
Reputation: 66999
You could use the GreenDao QueryBuilder to do SELECT
s. But this would be overkill for your example.
In your case, since you are simply dumping out the entire table, you can just use the loadAll() method of your entity's Dao class. This illustrates why using DAO is so powerful.
For example, if your entity is named "Seguimento", you can call: daoSession.getSeguimentoDao().loadAll()
, which will return a List<Seguimento>
.
Upvotes: 1