android-loadermanager

How can I refresh the cursor from a CursorLoader?

*爱你&永不变心* 提交于 2019-12-18 12:08:06
问题 So I have my MainDisplayActivity which implements both Activity and LoaderManager.LoaderCallbacks<Cursor> . Here I have A ListView , which I fill with Agenda information that I get from my database using a ContentProvider. I also have a GridView which is a calendar. I have it set up when clicking a cell, that the agenda is updated with the day clicked. My problem is that when reusing the Loader I created in onCreate() inside of the setOnItemClickListener(), it does not refresh the information

What to set CursorAdapter(Context context, Cursor c, int flags) to in order to make it work with CursorLoader?

耗尽温柔 提交于 2019-12-18 11:27:26
问题 The google docs point out not to use the CursorAdapters first constructor, CursorAdapter(Context context, Cursor c) There are only two other options, CursorAdapter(Context context, Cursor c, boolean autoRequery) which says Constructor that allows control over auto-requery. It is recommended you not use this, but instead CursorAdapter(Context, Cursor, int). When using this constructor, FLAG_REGISTER_CONTENT_OBSERVER will always be set.` and CursorAdapter(Context context, Cursor c, int flags)`

ActionBarSherlock + Maps + Loaders = java.lang.NoClassDefFoundError

烂漫一生 提交于 2019-12-18 04:12:55
问题 Edit: For a detailed how-to, check out my answer. I'm struggling with it for two days now, hope someone can help. I'm trying to use the newest ActionBarSherlock (4.0) with a MapView. I knew it's problematic with fragments, but I don't need them in this activity. But I need Loaders and it appears, that to use Loaders I have to extend the FragmentActivity too. No problem, I thought, we have the android-support-v4-googlemaps from Pete Doyle. As suggested on many SO threads and Google Groups I

How to transition from managedQuery to LoaderManager/CursorLoader?

时间秒杀一切 提交于 2019-12-17 17:45:22
问题 I'm developing an Android application that is targeting API level 8 (2.2, Froyo). I'm using a ContentProvider and that's simple enough, and I'm using SimpleCursorAdapter to fill out my list view, but I noticed in the documentation for SimpleCursorAdapter that the flagless constructor is deprecated with the following note: This constructor is deprecated. This option is discouraged, as it results in Cursor queries being performed on the application's UI thread and thus can cause poor

CursorLoader not updating after data change

我怕爱的太早我们不能终老 提交于 2019-12-17 06:29:29
问题 I have created a small application, trying to understand the functionality of the LoaderManager and CursorLoader -classes. I have implemented LoaderCallbacks<Cursor> on my FragmentActivity -class and everything works fine, except the fact that when I update my data via ContentResolver.update() or ContentResolver.insert() -methods, onLoadFinished() is not called and as a result my data doesn't update. I have a custom ContentProvider and I am wondering if the problem is in my ContentProvider

CursorLoader not updating after data change

自作多情 提交于 2019-12-17 06:29:07
问题 I have created a small application, trying to understand the functionality of the LoaderManager and CursorLoader -classes. I have implemented LoaderCallbacks<Cursor> on my FragmentActivity -class and everything works fine, except the fact that when I update my data via ContentResolver.update() or ContentResolver.insert() -methods, onLoadFinished() is not called and as a result my data doesn't update. I have a custom ContentProvider and I am wondering if the problem is in my ContentProvider

Using Singleton design pattern for SQLiteDatabase

≯℡__Kan透↙ 提交于 2019-12-17 00:27:15
问题 I'm rather newbie on Android, and I'm working on a simple application to get some basic experience. My app is pretty simple and consists among other things of a broadcast receiver and some activities. Both components make use of a single database, so in theory it could happen that both try to access the db concurrently. Currently I'm simply instantiating the db object (which is-a SQLite db helper class) each time I need it, and performing the needed operations: query, insert, etc. From what I

Why is Cursor.requery() marked “deprecated”?

最后都变了- 提交于 2019-12-13 14:29:01
问题 Cursor.requery() is a very common method while using it to refresh a ListView's content. But why is this method marked "deprecated"? I can't understand the reason on the API docs very clearly. Cursor.requery() API: http://developer.android.com/reference/android/database/Cursor.html#requery() Can anyone please explain the reason any further? Thanks:) 回答1: I believe it was done because new Loaders API was introduced to simplify querying Cursors asynchronously. As deprecation note says Don't use

Loader not retained and always created on orientation change

老子叫甜甜 提交于 2019-12-13 05:07:25
问题 I have an Activity A that contains a Fragment B that contains a Fragment C . Currently, Fragment B 's LoaderManager manages one CursorLoader . The data is given to Fragment C . On orientation change, the loader is lost: initLoader always leads to onCreateLoader being invoked by the system. However, the documentation says: If the loader doesn't already exist, one is created and (if the activity/fragment is currently started) starts the loader. Otherwise the last created loader is re-used. How

Writing Data managed by a LoaderManager

∥☆過路亽.° 提交于 2019-12-13 00:46:36
问题 When using a LoaderManager, do I still manage my database writes the way I have in the past and let the Loader pick up the changes? I am in the process of converting and adding functionality to an app and I am still getting used to the Android platform. 回答1: If you are using CursorLoader , and you do all your database updates via the ContentProvider you used with CursorLoader , the loader and its Cursor will be notified of changes, so everything will be handled for you. If you are not using