Skip to content

Instantly share code, notes, and snippets.

@iewnait
Created June 5, 2012 20:57
Show Gist options
  • Save iewnait/2877852 to your computer and use it in GitHub Desktop.
Save iewnait/2877852 to your computer and use it in GitHub Desktop.
Example code for Weather.query(ContentResolver cr, String[] projection, String where, String[] whereArgs, String orderBy)
String[] projections = new String [] {
Weather.Columns.CITY_UID,
Weather.Columns.NAME,
Weather.Columns.DATE,
Weather.Columns.TEMP_HIGH,
Weather.Columns.TEMP_LOW,
Weather.Columns.LONGITUDE,
Weather.Columns.LATITUDE
};
String selection = Weather.Columns.CITY_UID + " = ?";
String[] selectionArgs = new String[] {"103662"}; // Los Altos
// Sort data returned by Weather.Columns.DATE.
Cursor cur = Weather.query(getContext().getContentResolver(),
projections,
selection,
selectionArgs,
Weather.Columns.DATE
);
while (cur.moveToNext()) {
Weather.WeatherInfo wi = Weather.getWeatherInfoFromCursor(cur);
// Do something with these weather data.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment