Android - Cursor Loader

浪尽此生 提交于 2019-12-11 19:16:08

问题


I've been trying to use cursor loader.I started following this tutorial http://responsiveandroid.com/2012/03/19/using-an-android-cursor-loader-with-a-content-provider.html but could not understand.tutorial put me in chaos.

As far i know cursorloader is an adapter,adapter job is go to content provider take data then put the data in to view.

What does content resolver do ?

Android document says SimpleCursorAdapter is depreciated and says to use cursor adapter,this is the tutorial that i was talking http://responsiveandroid.com/2012/03/19/using-an-android-cursor-loader-with-a-content-provider.html

Here he uses both simplecursoradapter and cursor loader.Why is that ? Can any one explain me ,how to use cursor loader ?


回答1:


You are conflating two different things.

A cursorloader gets that data from your data source and loads it into a cursor then manages the cursor. A cursor is basically an in memory data storage construct.

An adapter takes the data from the cursor (or array or list) and puts into your display layout to be viewed.




回答2:


I think you can still use SimpleCursorAdapter. Looking at the documentation, it looks like the old constructor is deprecated but you can use another constructor which is this one:

SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) Standard constructor.

More details here: http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html



来源:https://stackoverflow.com/questions/12356462/android-cursor-loader

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