Created
June 5, 2012 20:57
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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