"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!
You need to do a requery() after changing anything in data source.
Up vote 0 down vote favorite share g+ share fb share tw.
I am having a list view with text and a button. The contents of the listview(the text) are fetched from the SQLite database. I have implemented the code such that, if anyone clicks the button, the corresponding flag of that list item changes in the database table.
My intention would be, as soon as the flag is changed in the database table, the corresponding list item should disappear from the list. Currently, I'm able to change the flag value for the list item (successfully updating in the corresponding column of the table), but the list item remains in the list view until I re-open the app. The list item then disappears as desired.
Is there a way such that as soon as I click the button, and as the flag value is changed at the background, the list refreshes and show me only other items of the list.? Your help will be much appreciated. Thanks in advance. Android sqlite listview link|improve this question asked Nov 29 '11 at 8:25kittu162.
– Abhinav Singh Maurya Nov 29 '11 at 8:38 build ContenProvider and use CursorLoader from v4 compat lib(look at sdk samples) ... you should use getContext(). GetContentResolver(). NotifyChange(...) in your update/insert/delete implementation of ContentProvider and refresh stuff will be done in CursorLoader(registering for change and requery) automaticly ... that's the "android way" ... you can even not use CursorLoader ... it will be done automaticly with deprecated requery ... so the only code that you need to write is ContentProvider – Selvin Nov 29 '11 at 8:45 ... don't forget to add return_cursor.
SetNotificationUri(getContext(). GetContentResolver(), uri) in query implementation of your ContentProvider ... (see NotePad sample in your sdk folder) – Selvin Nov 29 '11 at 9:07.
You need to do a requery() after changing anything in data source. -- Edit -- Just found that requery is deprecating, but anyway, the idea is the same. Query for another new Cursor, and set it in CursorAdapter (if you are using it).
Generally, for a ListView, you have to prepare an adapter for the ListView to provide the content of every item in the ListView. The basic idea is that in order to refresh the listview, you have to call adapter. NotifyDataSetChanged() to request the refreshment.
Query with a new Cursor and set the results in the CursorAdapter invalidate() the existing list view.
Thanks all for your responses. I have tried to do it in android way, but seems to be a bit complex. Hence inorder to refresh the list view after updating the list I have re-called the activity using intents so that I'll get a fresh list view with added or deleted list entries.
Hope I'll find other android way of solutions soon.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.