0

When I use SQLite to bring my data and use cursor and adapters, should I use cursor Loaders??. Is this the best practice?. Im not quite clear when to use cursor loaders. Should I use it only if my app shares data with other apps?. My question comes because it have been really annoying for me using cursors + adapters + listView; sometimes the notifyDataSetChanged works, sometimes not, so it have been really tricky sometimes. I start reading about cursor loaders but Im not sure if this is a work around for this in particular or if I can use it as a work around.

Any clarification will be really appreciated!!

Thanks guys.

4

1 回答 1

1

使用 Loaders 确保所有游标操作都是异步完成的,从而消除了阻塞 UI 线程的可能性。

使用 CursorAdapter 时不要使用 notifyDataSetChanged 而是使用:

db.updateData();
yourCursor = db.getData();  
yourAdapter.changeCursor(yourCursor);
于 2013-10-29T14:14:06.717 回答