Android how do you code now if requery is deprecated?

99封情书 提交于 2019-12-05 06:51:14
Mohammed Azharuddin Shaikh

again re-initialize cursor when your any DML query execute, can refer this

Rasel

Just think about a block where you need to use cursor again and again. Populate it with the query. Work with it and then close before reusing

{
    Cursor c =//Populating cursor again
    while (c.moveToNext()) {
    }
    if (c != null) c.close();
}

Use a Loader to manage your cursors. It will return a new Cursor as needed and you can use swapCursor() on the adapter to refresh the data.

I used ListAdapter.notifyDataSetChanged(); this worked only on list (like ArrayList), when the listcontent changed. Using databaseoutput, it doesn't work anymore. Therefore I took cursor.requery(); which is not only depricated. It also works only, if database entries changed.

But now, I want to change my view (switch between birthdays and dates) by changing my settings in a database, so requery does not recognize it.

For all changes works (a little bit dirty): this.onCreate(null);

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