In my Android application, I am using Sqlite DataBase to store the data from the server. I am using ContentProvider and ContentResolver to access the data from the DataBase and using CursorAdapter to bind the data to the ListView. As soon the data is inserted into the DataBase, CursorAdapter will be notified to update the ListView. Also, whenever I scroll the ListView, I get new data from the DataBase table and ListView will be updated. But once I reaches to the end of the table row, I need to fetch the data directly from the server without storing into the DataBase and update it in the ListView. Now as I am using CursorAdapter which accepts Cursor data, how can I bind a new set of data which is not coming from the DataBase? Is is possible to create Cursor data without getting data from the DataBase and use ChangeCursor() method in the ContentProvider to update the ListView? If not, is there any other method to achieve the same?
Asked
Active
Viewed 4,645 times
1 Answers
10
Is is possible to create Cursor data without getting data from the DataBase and use ChangeCursor() method in the ContentAdapter to update the ListView?
Yes, you can create cursor using MatrixCursor. If you will have to merge MatrixCursor with database Cursor use MergeCursor.

Leszek
- 6,568
- 3
- 42
- 53
-
Thanks for your answer. So where exactly I have to merge the cursors. Should it be done in onLoadFinished() method or query() method of ContentProvider while calling cursor.setNotificationUri()? – Vivek Apr 08 '13 at 09:35
-
In onLoadFinished() but you probably should download data from server before you init your loader(if possible) or refresh loader if you postpone downloading. – Leszek Apr 08 '13 at 17:35