I have a DatabaseHelper class which extends SQLiteOpenHelper, what is a good practice to using the DBHelper to perform data extractions?
In my DatabaseHelper class, I have a method to help me retrieve the results of a query like, “Select * FROM …..”. The results will be used by many other classes.
Example:
Cursor getAllWhitelist(){
SQLite Database db=this.getWritableDatabase();
Cursor cur = db.rawQuery("Select * from WhiteList");
return cur;
}
Should I be returning a cursor at this stage? Is it recommended? Or should I be returning an ArrayList or things like that?
How are you guys doing it?
What i used is, stored the value in some object or in some arraylist of object and return that
Refer this link
Thanks @Austyn Mahoney, as he told we can return cursor, if we use
startManagingCursor. This method allows the activity to take care of managing the given Cursor’s lifecycle for you based on the activity’s lifecycle.