Example usage for android.database Cursor getDouble

List of usage examples for android.database Cursor getDouble

Introduction

In this page you can find the example usage for android.database Cursor getDouble.

Prototype

double getDouble(int columnIndex);

Source Link

Document

Returns the value of the requested column as a double.

Usage

From source file:org.opensmc.mytracks.cyclesmc.TripUploader.java

private JSONObject getCoordsJSON(long tripId) throws JSONException {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);

    mDb.openReadOnly();/* w w w  . j a va2 s .  c  om*/
    Cursor tripCoordsCursor = mDb.fetchAllCoordsForTrip(tripId);

    // Build the map between JSON fieldname and phone db fieldname:
    Map<String, Integer> fieldMap = new HashMap<String, Integer>();
    fieldMap.put(TRIP_COORDS_TIME, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_TIME));
    fieldMap.put(TRIP_COORDS_LAT, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_LAT));
    fieldMap.put(TRIP_COORDS_LON, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_LGT));
    fieldMap.put(TRIP_COORDS_ALT, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_ALT));
    fieldMap.put(TRIP_COORDS_SPEED, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_SPEED));
    fieldMap.put(TRIP_COORDS_HACCURACY, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_ACC));
    fieldMap.put(TRIP_COORDS_VACCURACY, tripCoordsCursor.getColumnIndex(DbAdapter.K_POINT_ACC));

    // Build JSON objects for each coordinate:
    JSONObject tripCoords = new JSONObject();
    while (!tripCoordsCursor.isAfterLast()) {
        JSONObject coord = new JSONObject();

        coord.put(TRIP_COORDS_TIME, df.format(tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_TIME))));
        coord.put(TRIP_COORDS_LAT, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_LAT)));
        coord.put(TRIP_COORDS_LON, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_LON)));
        coord.put(TRIP_COORDS_ALT, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_ALT)));
        coord.put(TRIP_COORDS_SPEED, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_SPEED)));
        coord.put(TRIP_COORDS_HACCURACY, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_HACCURACY)));
        coord.put(TRIP_COORDS_VACCURACY, tripCoordsCursor.getDouble(fieldMap.get(TRIP_COORDS_VACCURACY)));

        tripCoords.put(coord.getString("rec"), coord);
        tripCoordsCursor.moveToNext();
    }
    tripCoordsCursor.close();
    mDb.close();
    return tripCoords;
}

From source file:com.syncedsynapse.kore2.ui.MovieDetailsFragment.java

/**
 * Display the movie details//from   w  ww  . j  av a 2s . com
 *
 * @param cursor Cursor with the data
 */
private void displayMovieDetails(Cursor cursor) {
    LogUtils.LOGD(TAG, "Refreshing movie details");
    cursor.moveToFirst();
    String movieTitle = cursor.getString(MovieDetailsQuery.TITLE);
    mediaTitle.setText(movieTitle);
    mediaUndertitle.setText(cursor.getString(MovieDetailsQuery.TAGLINE));

    int runtime = cursor.getInt(MovieDetailsQuery.RUNTIME) / 60;
    String durationYear = runtime > 0
            ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                    + String.valueOf(cursor.getInt(MovieDetailsQuery.YEAR))
            : String.valueOf(cursor.getInt(MovieDetailsQuery.YEAR));
    mediaYear.setText(durationYear);
    mediaGenres.setText(cursor.getString(MovieDetailsQuery.GENRES));

    double rating = cursor.getDouble(MovieDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRatingVotes.setVisibility(View.VISIBLE);
        mediaRating.setText(String.format("%01.01f", rating));
        mediaMaxRating.setText(getString(R.string.max_rating_video));
        String votes = cursor.getString(MovieDetailsQuery.VOTES);
        mediaRatingVotes
                .setText((TextUtils.isEmpty(votes)) ? "" : String.format(getString(R.string.votes), votes));
    } else {
        mediaRating.setVisibility(View.INVISIBLE);
        mediaMaxRating.setVisibility(View.INVISIBLE);
        mediaRatingVotes.setVisibility(View.INVISIBLE);
    }

    mediaDescription.setText(cursor.getString(MovieDetailsQuery.PLOT));
    mediaDirectors.setText(cursor.getString(MovieDetailsQuery.DIRECTOR));

    // IMDB button
    imdbButton.setTag(cursor.getString(MovieDetailsQuery.IMDBNUMBER));

    setupSeenButton(cursor.getInt(MovieDetailsQuery.PLAYCOUNT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager,
            cursor.getString(MovieDetailsQuery.THUMBNAIL), movieTitle, mediaPoster, posterWidth, posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(hostManager, cursor.getString(MovieDetailsQuery.FANART), mediaArt,
            displayMetrics.widthPixels, artHeight);

    // Setup movie download info
    movieDownloadInfo = new FileDownloadHelper.MovieInfo(movieTitle, cursor.getString(MovieDetailsQuery.FILE));

    // Check if downloaded file exists
    downloadButton.setVisibility(View.VISIBLE);
    if (movieDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.syncedsynapse.kore2.ui.TVShowEpisodeDetailsFragment.java

/**
 * Display the episode details//from  w  w  w. ja  v  a  2 s  . co m
 *
 * @param cursor Cursor with the data
 */
private void displayEpisodeDetails(Cursor cursor) {
    cursor.moveToFirst();
    mediaTitle.setText(cursor.getString(EpisodeDetailsQuery.TITLE));
    mediaUndertitle.setText(cursor.getString(EpisodeDetailsQuery.SHOWTITLE));

    int runtime = cursor.getInt(EpisodeDetailsQuery.RUNTIME) / 60;
    String durationPremiered = runtime > 0
            ? String.format(getString(R.string.minutes_abbrev), String.valueOf(runtime)) + "  |  "
                    + cursor.getString(EpisodeDetailsQuery.FIRSTAIRED)
            : cursor.getString(EpisodeDetailsQuery.FIRSTAIRED);
    mediaPremiered.setText(durationPremiered);
    String season = String.format(getString(R.string.season_episode), cursor.getInt(EpisodeDetailsQuery.SEASON),
            cursor.getInt(EpisodeDetailsQuery.EPISODE));
    mediaSeason.setText(season);

    double rating = cursor.getDouble(EpisodeDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        mediaRating.setText(String.format("%01.01f", rating));
        mediaMaxRating.setText(getString(R.string.max_rating_video));
    } else {
        mediaRating.setVisibility(View.INVISIBLE);
        mediaMaxRating.setVisibility(View.INVISIBLE);
    }

    mediaDescription.setText(cursor.getString(EpisodeDetailsQuery.PLOT));
    mediaDirectors.setText(cursor.getString(EpisodeDetailsQuery.DIRECTOR));

    setupSeenButton(cursor.getInt(EpisodeDetailsQuery.PLAYCOUNT));

    // Images
    Resources resources = getActivity().getResources();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    //        UIUtils.loadImageIntoImageview(hostManager,
    //                cursor.getString(EpisodeDetailsQuery.THUMBNAIL),
    //                mediaPoster, posterWidth, posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(hostManager, cursor.getString(EpisodeDetailsQuery.THUMBNAIL), mediaArt,
            displayMetrics.widthPixels, artHeight);

    // Setup movie download info
    tvshowDownloadInfo = new FileDownloadHelper.TVShowInfo(cursor.getString(EpisodeDetailsQuery.SHOWTITLE),
            cursor.getInt(EpisodeDetailsQuery.SEASON), cursor.getInt(EpisodeDetailsQuery.EPISODE),
            cursor.getString(EpisodeDetailsQuery.TITLE), cursor.getString(EpisodeDetailsQuery.FILE));

    // Check if downloaded file exists
    downloadButton.setVisibility(View.VISIBLE);
    if (tvshowDownloadInfo.downloadFileExists()) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme.obtainStyledAttributes(new int[] { R.attr.colorAccent });
        downloadButton.setColorFilter(styledAttributes.getColor(0, R.color.accent_default));
        styledAttributes.recycle();
    } else {
        downloadButton.clearColorFilter();
    }
}

From source file:com.enadein.carlogbook.ui.AddUpdateFuelLogActivity.java

@Override
protected void populateEditEntity() {
    Cursor logCursor = getContentResolver().query(ProviderDescriptor.Log.CONTENT_URI, null, ID_PARAM,
            new String[] { String.valueOf(id) }, null);
    if (logCursor != null && logCursor.moveToFirst()) {
        int odometerIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.ODOMETER);
        int priceIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.PRICE);
        int dateIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.DATE);
        int fueldValueIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.FUEL_VOLUME);
        int fuelTypePosIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.FUEL_TYPE_ID);
        int fuelStationPosIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.FUEL_STATION_ID);

        int commentIdx = logCursor.getColumnIndex(ProviderDescriptor.Log.Cols.CMMMENT);
        comments.setText(logCursor.getString(commentIdx));

        odomenterView.setText(String.valueOf(logCursor.getLong(odometerIdx)));
        priceView.setText(CommonUtils.formatPriceNew(logCursor.getDouble(priceIdx), unitFacade));
        date = new Date(logCursor.getLong(dateIdx));
        fuelValueView.setText(CommonUtils.formatFuel(logCursor.getDouble(fueldValueIdx), unitFacade));

        new PriceState().updatePrice();
        fuelTypeSpinner.setSelection(getPositionFromAdapterById(fuelAdapter, logCursor.getInt(fuelTypePosIdx)));

        stationSpinner/*from w w  w  .ja v a 2  s  .c  o  m*/
                .setSelection(getPositionFromAdapterById(stationAdapter, logCursor.getInt(fuelStationPosIdx)));

    }
}

From source file:com.aafr.alfonso.sunshine.app.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        // Read weather condition ID from cursor
        int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
        // Use weather art image
        mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

        // Read date from cursor and update views for day of week and date
        String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
        String friendlyDateText = Utility.getDayName(getActivity(), date);
        String dateText = Utility.getFormattedMonthDay(getActivity(), date);
        mFriendlyDateView.setText(friendlyDateText);
        mDateView.setText(dateText);/*from  www .j ava 2s  . c o m*/

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
        mDescriptionView.setText(description);

        // For accessibility, add a content description to the icon field
        mIconView.setContentDescription(description);

        // Read high temperature from cursor and update view
        boolean isMetric = Utility.isMetric(getActivity());

        double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
        String highString = Utility.formatTemperature(getActivity(), high, isMetric);
        mHighTempView.setText(highString);

        // Read low temperature from cursor and update view
        double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
        String lowString = Utility.formatTemperature(getActivity(), low, isMetric);
        mLowTempView.setText(lowString);

        // Read humidity from cursor and update view
        float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

        // Read wind speed and direction from cursor and update view
        float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
        float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

        // Read pressure from cursor and update view
        float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
        mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

        // We still need this for the share intent
        mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

        // If onCreateOptionsMenu has already happened, we need to update the share intent now.
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createShareForecastIntent());
        }
    }
}

From source file:com.demo.weather.sunshine.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        // Read weather condition ID from cursor
        int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
        // Use weather art image
        mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

        // Read date from cursor and update views for day of week and date
        String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
        String friendlyDateText = Utility.getDayName(getActivity(), date);
        String dateText = Utility.getFormattedMonthDay(getActivity(), date);
        mFriendlyDateView.setText(friendlyDateText);
        mDateView.setText(dateText);// w  w  w  .j  a v a2 s.  co m

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
        mDescriptionView.setText(description);

        // For accessibility, add a content description to the icon field
        mIconView.setContentDescription(description);

        // Read high temperature from cursor and update view
        boolean isMetric = Utility.isMetric(getActivity());

        double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString);

        // Read low temperature from cursor and update view
        double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
        String lowString = Utility.formatTemperature(getActivity(), low);
        mLowTempView.setText(lowString);

        // Read humidity from cursor and update view
        float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

        // Read wind speed and direction from cursor and update view
        float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
        float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

        // Read pressure from cursor and update view
        float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
        mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

        // We still need this for the share intent
        mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

        // If onCreateOptionsMenu has already happened, we need to update the share intent now.
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createShareForecastIntent());
        }
    }
}

From source file:com.digitalconstruction.myapplication.DetailFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
        // Read weather condition ID from cursor
        int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
        // Use weather art image
        mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

        // Read date from cursor and update views for day of week and date
        String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
        String friendlyDateText = Utility.getDayName(getActivity(), date);
        String dateText = Utility.getFormattedMonthDay(getActivity(), date);
        mFriendlyDateView.setText(friendlyDateText);
        mDateView.setText(dateText);/*www .  j  av a2 s  .c  o  m*/

        // Read description from cursor and update view
        String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
        // For accessibility, add a content description to the icon field
        mIconView.setContentDescription(description);
        mDescriptionView.setText(description);

        // Read high temperature from cursor and update view
        boolean isMetric = Utility.isMetric(getActivity());

        double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
        String highString = Utility.formatTemperature(getActivity(), high);
        mHighTempView.setText(highString);

        // Read low temperature from cursor and update view
        double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
        String lowString = Utility.formatTemperature(getActivity(), low);
        mLowTempView.setText(lowString);

        // Read humidity from cursor and update view
        float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
        mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

        // Read wind speed and direction from cursor and update view
        float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
        float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
        mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
        Log.d("MARK", "wind: Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr");

        // Read pressure from cursor and update view
        float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
        mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

        // We still need this for the share intent
        mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

        // If onCreateOptionsMenu has already happened, we need to update the share intent now.
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createShareForecastIntent());
        }
    }
}

From source file:com.example.xiaoma.myapplication.model.DoHttpPostJson.java

/**
 * Post????Json?//from  ww w. ja  v  a2 s  .  co  m
 * BMS1?2
 */
@Override
public void carattribute(final Context context, final String url) {
    new Thread() {
        @Override
        public void run() {
            final String Url = url;
            Context mContext = context;
            myDBHelper = new MyDBOpenHelper(mContext, "db_ebike", null, 1);
            db = myDBHelper.getWritableDatabase();
            /**
             * ??JsonJSONObject
             */
            String licensenumber = ""; // ?
            String bms_hardwareversion = ""; // BMS?
            String bms_softwareversion = ""; // BMS?
            int cell_cap_rated = 0; // ??
            String cell_type = ""; // 
            int cell_box_nums = 0; // 
            int cell_serial_nums = 0; // 
            double volalarmhigh = 0; // ?
            double volcutoffhigh = 0; // ?
            double volalarmlow = 0; // 
            double volcutofflow = 0; // 
            double volalarmhigh_single = 0; // ??
            double volcutoffhigh_single = 0; // ??
            double volalarmlow_single = 0; // ?
            double volcutofflow_single = 0; // ?
            double tmpalarmhigh = 0; // ?
            double tmpcutoffhigh = 0; // ?
            double tmpalarmlow = 0; // ?
            double tmpcutofflow = 0; // ?
            double in_elealarmhigh = 0; // ?
            double in_elecutoffhigh = 0; // ?
            double out_elealarmhigh = 0; // ?
            double out_elecutoffhigh = 0; // ?
            double voldiff_alarmhigh = 0; // 
            double voldiff_cutoffhigh = 0; // 
            JSONObject jsonObj = new JSONObject();
            Cursor cursor = db.query("tb_carattribute", null, null, null, null, null, null);
            if (cursor.moveToFirst()) {
                do {
                    //int id = cursor.getInt(cursor.getColumnIndex("id"));
                    licensenumber = cursor.getString(cursor.getColumnIndex("licensenumber"));
                    bms_hardwareversion = cursor.getString(cursor.getColumnIndex("bms_hardwareversion"));
                    bms_softwareversion = cursor.getString(cursor.getColumnIndex("bms_softwareversion"));
                    cell_cap_rated = cursor.getInt(cursor.getColumnIndex("cell_cap_rated"));
                    cell_type = cursor.getString(cursor.getColumnIndex("cell_type"));
                    cell_box_nums = cursor.getInt(cursor.getColumnIndex("cell_box_nums"));
                    cell_serial_nums = cursor.getInt(cursor.getColumnIndex("cell_serial_nums"));
                    volalarmhigh = cursor.getDouble(cursor.getColumnIndex("volalarmhigh"));
                    volcutoffhigh = cursor.getDouble(cursor.getColumnIndex("volcutoffhigh"));
                    volalarmlow = cursor.getDouble(cursor.getColumnIndex("volalarmlow"));
                    volcutofflow = cursor.getDouble(cursor.getColumnIndex("volcutofflow"));
                    volalarmhigh_single = cursor.getDouble(cursor.getColumnIndex("volalarmhigh_single"));
                    volcutoffhigh_single = cursor.getDouble(cursor.getColumnIndex("volcutoffhigh_single"));
                    volalarmlow_single = cursor.getDouble(cursor.getColumnIndex("volalarmlow_single"));
                    volcutofflow_single = cursor.getDouble(cursor.getColumnIndex("volcutofflow_single"));
                    tmpalarmhigh = cursor.getDouble(cursor.getColumnIndex("tmpalarmhigh"));
                    tmpcutoffhigh = cursor.getDouble(cursor.getColumnIndex("tmpcutoffhigh"));
                    tmpalarmlow = cursor.getDouble(cursor.getColumnIndex("tmpalarmlow"));
                    tmpcutofflow = cursor.getDouble(cursor.getColumnIndex("tmpcutofflow"));
                    in_elealarmhigh = cursor.getDouble(cursor.getColumnIndex("in_elealarmhigh"));
                    in_elecutoffhigh = cursor.getDouble(cursor.getColumnIndex("in_elecutoffhigh"));
                    out_elealarmhigh = cursor.getDouble(cursor.getColumnIndex("out_elealarmhigh"));
                    out_elecutoffhigh = cursor.getDouble(cursor.getColumnIndex("out_elecutoffhigh"));
                    voldiff_alarmhigh = cursor.getDouble(cursor.getColumnIndex("voldiff_alarmhigh"));
                    voldiff_cutoffhigh = cursor.getDouble(cursor.getColumnIndex("voldiff_cutoffhigh"));
                    try {
                        jsonObj.put("licensenumber", licensenumber)
                                .put("bms_hardwareversion", bms_hardwareversion)
                                .put("bms_softwareversion", bms_softwareversion)
                                .put("cell_cap_rated", cell_cap_rated).put("cell_type", cell_type)
                                .put("cell_box_nums", cell_box_nums).put("cell_serial_nums", cell_serial_nums)
                                .put("volalarmhigh", volalarmhigh).put("volcutoffhigh", volcutoffhigh)
                                .put("volalarmlow", volalarmlow).put("volcutofflow", volcutofflow)
                                .put("volalarmhigh_single", volalarmhigh_single)
                                .put("volcutoffhigh_single", volcutoffhigh_single)
                                .put("volalarmlow_single", volalarmlow_single)
                                .put("volcutofflow_single", volcutofflow_single)
                                .put("tmpalarmhigh", tmpalarmhigh).put("tmpcutoffhigh", tmpcutoffhigh)
                                .put("tmpalarmlow", tmpalarmlow).put("tmpcutofflow", tmpcutofflow)
                                .put("in_elealarmhigh", in_elealarmhigh)
                                .put("in_elecutoffhigh", in_elecutoffhigh)
                                .put("out_elealarmhigh", out_elealarmhigh)
                                .put("out_elecutoffhigh", out_elecutoffhigh)
                                .put("voldiff_alarmhigh", voldiff_alarmhigh)
                                .put("voldiff_cutoffhigh", voldiff_cutoffhigh);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                } while (cursor.moveToNext());
            }
            cursor.close();
            String jsonString = jsonObj.toString();

            // Post?
            List<NameValuePair> nameValuePairs = new ArrayList<>();
            nameValuePairs.add(new BasicNameValuePair("data", jsonString));

            try {
                //?HTTP
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost httpPost = new HttpPost(Url);
                httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                System.out.println("executing request " + httpPost.getURI());

                HttpResponse httpResponse = httpClient.execute(httpPost);
                try {
                    HttpEntity httpEntity = httpResponse.getEntity();
                    if (httpEntity != null) {
                        System.out.println("--------------------------------------");
                        System.out.println("Response content: " + EntityUtils.toString(httpEntity, "UTF-8"));
                        System.out.println("--------------------------------------");
                    }
                } finally {
                    System.out.println("--------------------------------------");
                }
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }.start();
}

From source file:com.sf.tracem.db.DBManager.java

private List<Operation> getOperationsFrom(Cursor cursor) {
    List<Operation> operations = new ArrayList<Operation>();

    if (cursor.moveToFirst()) {

        Map<String, Integer> columnMap = getColumnMap(cursor, Operation.COLUMN_NAMES);
        do {/*from  w w  w .jav a 2  s  .c om*/
            Operation operation = new Operation();

            operation.setAufnr(cursor.getString(columnMap.get(Operation.AUFNR)));
            operation.setACTIVITY(cursor.getString(columnMap.get(Operation.ACTIVITY)));
            operation.setCOMPLETE(cursor.getInt(columnMap.get(Operation.COMPLETE)));
            operation.setDESCRIPTION(cursor.getString(columnMap.get(Operation.DESCRIPTION)));
            operation.setDURATION_NORMAL(cursor.getDouble(columnMap.get(Operation.DURATION_NORMAL)));
            operation.setDURATION_NORMAL_UNIT(cursor.getString(columnMap.get(Operation.DURATION_NORMAL_UNIT)));
            operation.setPLANT(cursor.getString(columnMap.get(Operation.PLANT)));
            operation.setWORK_CNTR(cursor.getString(columnMap.get(Operation.WORK_CNTR)));
            operation.setCommited(cursor.getInt(columnMap.get(Operation.COMMITED)));
            operations.add(operation);
        } while (cursor.moveToNext());
    }

    return operations;
}

From source file:cn.apputest.ctria.sql.DBManager.java

/**
 * ??/*from  w  ww.  j a  v  a 2s. c  om*/
 * 
 * @return
 */
public ArrayList<BasestationDataEntity> queryBasestation() {

    Cursor c = queryTheCursorBasestation();
    ArrayList<BasestationDataEntity> bases = new ArrayList<BasestationDataEntity>();
    while (c.moveToNext()) {
        BasestationDataEntity base = new BasestationDataEntity();

        base.setName(c.getString(c.getColumnIndex("NAME")));
        LatLng l = new LatLng(c.getDouble(c.getColumnIndex("ALTITUDE")),
                c.getDouble(c.getColumnIndex("LATITUDE")));
        base.setIsbasestation(true);
        base.setLatlng(l);
        bases.add(base);
    }
    c.close();

    return bases;
}