1*90c8c64dSAndroid Build Coastguard Worker<p>This sample demonstrates how to create a list-based widget specifically backed by a content provider.<br/> 2*90c8c64dSAndroid Build Coastguard Worker<em>Please make sure that you understand the earlier stack widget sample code before delving into this example 3*90c8c64dSAndroid Build Coastguard Worker (see <a href="../StackWidget/index.html">StackWidget</a>).</em></p> 4*90c8c64dSAndroid Build Coastguard Worker 5*90c8c64dSAndroid Build Coastguard Worker<p>As in the StackWidget example, we will be using a collection view (the ListView in this case) to 6*90c8c64dSAndroid Build Coastguard Workerpresent some mock weather data in a widget. In particular, we will be using a content provider to 7*90c8c64dSAndroid Build Coastguard Workerdemonstrate how the widget can retrieve data and update itself when you are using more complex data 8*90c8c64dSAndroid Build Coastguard Workersources. When working with external data, or data which must be fetched over high latency, it is 9*90c8c64dSAndroid Build Coastguard Workerimportant to keep the data cached in a persistent location so that the widget feels responsive.</p> 10*90c8c64dSAndroid Build Coastguard Worker 11*90c8c64dSAndroid Build Coastguard Worker<p>This sample uses the following classes: 12*90c8c64dSAndroid Build Coastguard Worker <ul> 13*90c8c64dSAndroid Build Coastguard Worker <li><a href="src/com/example/android/weatherlistwidget/WeatherDataProvider.html"><code>WeatherDataProvider</code></a> — 14*90c8c64dSAndroid Build Coastguard Worker Our ContentProvider which stores the weather data for this sample. Note that for simplicity, 15*90c8c64dSAndroid Build Coastguard Worker it currently stores the data in memory as opposed to an external and persistent storage such 16*90c8c64dSAndroid Build Coastguard Worker as a file, network location, database, or shared preference. 17*90c8c64dSAndroid Build Coastguard Worker </li> 18*90c8c64dSAndroid Build Coastguard Worker <li><a href="src/com/example/android/weatherlistwidget/WeatherWidgetProvider.html"><code>WeatherWidgetProvider</code></a> — 19*90c8c64dSAndroid Build Coastguard Worker Our AppWidgetProvider which handles specific intent actions (such as when an item is clicked, 20*90c8c64dSAndroid Build Coastguard Worker or the refresh button is pressed). It also sets up the RemoteViews for the widget and binds 21*90c8c64dSAndroid Build Coastguard Worker the service to the collection view in the widget. 22*90c8c64dSAndroid Build Coastguard Worker </li> 23*90c8c64dSAndroid Build Coastguard Worker <li><a href="src/com/example/android/weatherlistwidget/WeatherWidgetService.html"><code>WeatherWidgetService</code></a> — 24*90c8c64dSAndroid Build Coastguard Worker Our RemoteViewsService which manages the creation of new factories, which return the RemoteViews 25*90c8c64dSAndroid Build Coastguard Worker for each item in the ListView. 26*90c8c64dSAndroid Build Coastguard Worker </li> 27*90c8c64dSAndroid Build Coastguard Worker </ul> 28*90c8c64dSAndroid Build Coastguard Worker</p> 29*90c8c64dSAndroid Build Coastguard Worker 30*90c8c64dSAndroid Build Coastguard Worker<p>If you are writing collection-based widgets, remember that the feature is 31*90c8c64dSAndroid Build Coastguard Workersupported only on Android 3.0 (API level 11) and higher versions of the platform. 32*90c8c64dSAndroid Build Coastguard WorkerRemember to add the following to the application's manifest publishing to Google Play:</p> 33*90c8c64dSAndroid Build Coastguard Worker 34*90c8c64dSAndroid Build Coastguard Worker<ul> 35*90c8c64dSAndroid Build Coastguard Worker<li><code><uses-sdk android:minSdkVersion="11" /></code>, which indicates 36*90c8c64dSAndroid Build Coastguard Workerto Google Play and the platform that your application requires Android 3.0 or 37*90c8c64dSAndroid Build Coastguard Workerhigher. For more information, see the <a href="../../../guide/appendix/api-levels.html">API Levels</a> 38*90c8c64dSAndroid Build Coastguard Workerand the documentation for the 39*90c8c64dSAndroid Build Coastguard Worker<a href="../../../guide/topics/manifest/uses-sdk-element.html"><code><uses-sdk></code></a> 40*90c8c64dSAndroid Build Coastguard Workerelement.</li> 41*90c8c64dSAndroid Build Coastguard Worker</ul> 42*90c8c64dSAndroid Build Coastguard Worker 43*90c8c64dSAndroid Build Coastguard Worker<img alt="Screenshot" src="../images/WeatherListWidget.png" />