Android widget update the existing views
<p>I am developing an Android widget. I have an initial layout from the XML for my widget.</p>

<p>But I issued a webservice call and need to update the view according to the response from the webservice.</p>

<pre><code>public void changeTheApartmentTo(Context context, int position){
    remoteViews.setTextViewText(R.id.header_text, objj.get(position).getDistance());
    remoteViews.setTextViewText(R.id.text_name_row, objj.get(position).getName());
    remoteViews.setTextViewText(R.id.text_address_row, objj.get(position).getStreet());
    remoteViews.setTextViewText(R.id.text_state_row, objj.get(position).getState());
    remoteViews.setTextViewText(R.id.text_price_row, objj.get(position).getPrice());
    remoteViews.setTextViewText(R.id.text_bedbath_row, objj.get(position).getBathrooms());
    remoteViews.setImageViewBitmap(R.id.img_apartment, ImageLoader.getInstance().get(objj.elementAt(position).getImageUrl()));

    appWidgetManager.updateAppWidget(thisWidget, remoteViews);
}
</code></pre>

<p>Above is a function I have written in the <code>public class HelloWidget extends AppWidgetProvider</code>
class.</p>

<p>When I am changing the views, it results in a null pointer error.</p>
