samedi 14 février 2015

How to Lazy Load a Cursor On Scroll

hello mates hope you having a nice day, i have a database with about 1million rows inside it (up to 15m) and i need to load them on an ExpandableListView. my database has a shared _id collumn with my server , and they are never deleted ,they have a collumn with identifies their STATUS_AVAILABLE and STATUS_UNAVAILABLE modes and i need to load only available one's. obviously Loading all of them With Cursor takes too long and too much memory even without calling getCount(), so i Decided to Do This on my listview's adapter :



Cursor mCursor = MyService.getMapsActivity_DB().rawQuery("SELECT * FROM "+"'"+getGroup(groupPosition)+"'"+" WHERE _id="+"'"+groupPosition+"'", null);
mCursor.moveToPosition(childPosition);


and load them one by one, but my cursor counts only for available items :



Cursor mCursor = getInformer().OnGetDatabase().rawQuery("SELECT COUNT(*) FROM "+"'"+getGroup(groupPosition)+"'"+ApplyChildLoadCondition(), getInformer().ChildSelectionArgs());


there gonna be a misaligment in the id and groupPosition. so basically what im asking for is how can i query my database to get for example like this :



"SELECT * FROM table WHERE col_status = status_available POSITION = 999999, null);


but even if there is such thing, i guess it is gonna take while since it should count to the position, so best way to do so is lazy loading into a cursor or into a ArrayList, is there any way that i can lazy load cursor on scroll without losing position on them listview ? (index bar)


Aucun commentaire:

Enregistrer un commentaire