How to create Cursor data without getting data from the DataBase in Android application?

痞子三分冷 提交于 2019-12-08 15:38:22

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/15860619/how-to-create-cursor-data-without-getting-data-from-the-database-in-android-appl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!