jeudi 7 janvier 2016

Android : How to iterate on object attributes?

Cursor cursor_daily_data = db.query(TABLE_DAILY_DATA, null, null, null, null, null, null);
    if (cursor_daily_data.moveToFirst()) {
        do {
            DailyData dailyData = new DailyData();
            dailyData.time = cursor_daily_data.getString(0);
            dailyData.summary = cursor_daily_data.getString(1);
            dailyData.icon = cursor_daily_data.getString(2);
            dailyData.sunriseTime = cursor_daily_data.getString(3);
            dailyData.sunsetTime = cursor_daily_data.getString(4);
            dailyData.moonPhase = cursor_daily_data.getString(5);
            dailyData.precipIntensity = cursor_daily_data.getString(6);
            dailyData.precipIntensityMax = cursor_daily_data.getString(7);
            apiResponse.daily.data.add(dailyData);
        } while (cursor_daily_data.moveToNext());
    }
    cursor_daily_data.close();
    db.close();

Is there any better way to do this operation? I do not want to use any external libraries like sugar orm ..etc

Aucun commentaire:

Enregistrer un commentaire