Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid ListView not being update with Database Transactions
    text
    copied!<p>I am currently building an application that downloads data from facebook using their graph API.</p> <p>I am facing a very weird problem.. The data that I get from facebook is really huge so I use SqliteDatabase transaction to insert everything at once.</p> <p>Now I have two table where the data is being inserted one which is called event and the other which is called event_friend</p> <p>I created a list view whose adapter contains a query which is the join of both the above tables. Now every time a transaction finishes some number of rows are added in both the tables as a result the listView should also update. I found out that to do this we need to call notifyDataSetChanged of the adapter. I even tried doing that by sending a broadcast intent when the transaction is over and then calling notifyDataSetChanged but there were no rows in the listview.</p> <p>However when the activity resumes then the listView is filled with rows.</p> <p>Here is the relevant snippet from OnCreate</p> <blockquote> <blockquote> <p>Cursor c = managedQuery(CrowdSpottrProvider.CONTENT_URI_FRIENDS_POPULAR_VIRTUAL_TABLE, null, null, null, null);</p> <p>mListAdapterFriends = new EventsFriendsAdapter(this, R.layout.event_item, c, new String[]{"name", "friends", "start_time", "end_time"}, new int[] {R.events_list.event_name, R.events_list.number_of_friends_attending}, 2); mListView.setAdapter(mListAdapterFriends);</p> <p>mReciever = new BroadcastReceiver() {</p> <pre><code> @Override public void onReceive(Context context, Intent </code></pre> <p>intent) {</p> <pre><code> mListAdapterFriends.notifyDataSetChanged(); } }; registerReceiver(mReciever, new IntentFilter("events_added")); </code></pre> </blockquote> </blockquote> <p>Also the thread added entries as follows:</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload