List of usage examples for android.database Cursor getDouble
double getDouble(int columnIndex);
From source file:fr.poucedor.poucedor.MapActivity.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (data != null) { while (data.moveToNext()) { double furthestLatitude = data .getDouble(data.getColumnIndex(DatabaseContract.Team.COLUMN_NAME_FD_LATITUDE)); double furthestLongitude = data .getDouble(data.getColumnIndex(DatabaseContract.Team.COLUMN_NAME_FD_LONGITUDE)); String teamName = data.getString(data.getColumnIndex(DatabaseContract.Team.COLUMN_NAME_NAME)); myItemizedOverlay.addItem(new GeoPoint(furthestLatitude, furthestLongitude), teamName, null); }/* w w w .j a va 2 s . c om*/ } }
From source file:com.rappsantiago.weighttracker.progress.AddEditProgressFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { if (null != data && 0 < data.getCount() && data.moveToFirst()) { double weight = data.getDouble(DbConstants.IDX_PROGRESS_WEIGHT); double bodyFatIndex = data.getDouble(DbConstants.IDX_PROGRESS_BODY_FAT_INDEX); long dateInMillis = data.getLong(DbConstants.IDX_PROGRESS_TIMESTAMP); mTxtNewWeightWrapper.getEditText().setText(DisplayUtil.getWeightString(getActivity(), weight, null)); mTxtNewBodyFatIndexWrapper.getEditText().setText(String.format("%.2f", bodyFatIndex)); mDateInMillis = dateInMillis;/*from ww w .j a v a2 s . c om*/ mLblDate.setText(DisplayUtil.getReadableDate(dateInMillis)); } }
From source file:com.example.edwin.car2charge.MainActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { String[] projection = { CarDatabase.C_LAT, CarDatabase.C_LONG, CarDatabase.C_ADDRESS, CarDatabase.C_LICENSE, CarDatabase.C_BATTERY };//from w w w.j a v a 2s. com Cursor cursor = getContentResolver().query( Uri.withAppendedPath(CarDataProvider.CONTENT_URI, String.valueOf(id)), projection, null, null, null); cursor.moveToFirst(); double lat = cursor.getDouble(0); double lng = cursor.getDouble(1); Intent i = new Intent(getApplicationContext(), DetailActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); i.putExtra("lat", lat); i.putExtra("long", lng); i.putExtra("address", cursor.getString(2)); i.putExtra("license", cursor.getString(3)); i.putExtra("battery", cursor.getString(4)); startActivity(i); cursor.close(); }
From source file:planets.position.PlanetData.java
private void fillData() { Calendar c = Calendar.getInstance(); Cursor plCursor = cr.query(Uri.withAppendedPath(PlanetsDbProvider.PLANETS_URI, String.valueOf(planetNum)), projection, null, null, null); plCursor.moveToFirst();/*from ww w .j a v a 2s. com*/ planetName.setText(plCursor.getString(plCursor.getColumnIndexOrThrow("name"))); raText.setText(convertRaDec(plCursor.getDouble(plCursor.getColumnIndexOrThrow("ra")), 0)); decText.setText(convertRaDec(plCursor.getDouble(plCursor.getColumnIndexOrThrow("dec")), 1)); azText.setText(convertRaDec(plCursor.getDouble(plCursor.getColumnIndexOrThrow("az")), 3)); altText.setText(convertRaDec(plCursor.getDouble(plCursor.getColumnIndexOrThrow("alt")), 3)); disText.setText(convertRaDec(plCursor.getDouble(plCursor.getColumnIndexOrThrow("dis")), 2)); magText.setText(plCursor.getString(plCursor.getColumnIndexOrThrow("mag"))); c.setTimeInMillis(plCursor.getLong(plCursor.getColumnIndexOrThrow("setT"))); setTimeText.setText(DateFormat.format("MMM dd h:mm aa", c)); }
From source file:com.clutch.ClutchStats.java
public ArrayList<ABRow> getABLogs() { SQLiteDatabase db = getReadableDatabase(); String[] args = {};//w ww .j av a 2 s. com ArrayList<ABRow> res = new ArrayList<ABRow>(); Cursor cur = db.rawQuery("SELECT uuid, ts, data FROM ablog ORDER BY ts", args); cur.moveToFirst(); while (!cur.isAfterLast()) { String uuid = cur.getString(0); double ts = cur.getDouble(1); JSONObject data; try { data = new JSONObject(cur.getString(2)); } catch (JSONException e) { Log.w(TAG, "Could not serialize to JSON: " + cur.getString(3)); cur.moveToNext(); continue; } res.add(new ABRow(uuid, ts, data)); cur.moveToNext(); } db.close(); return res; }
From source file:com.clutch.ClutchStats.java
public ArrayList<StatRow> getLogs() { SQLiteDatabase db = getReadableDatabase(); String[] args = {};/*from w w w .java2s. com*/ ArrayList<StatRow> res = new ArrayList<StatRow>(); Cursor cur = db.rawQuery("SELECT uuid, ts, action, data FROM stats ORDER BY ts", args); cur.moveToFirst(); while (!cur.isAfterLast()) { String uuid = cur.getString(0); double ts = cur.getDouble(1); String action = cur.getString(2); JSONObject data; try { data = new JSONObject(cur.getString(3)); } catch (JSONException e) { Log.w(TAG, "Could not serialize to JSON: " + cur.getString(3)); cur.moveToNext(); continue; } res.add(new StatRow(uuid, ts, action, data)); cur.moveToNext(); } db.close(); return res; }
From source file:org.fitchfamily.android.wifi_backend.database.Database.java
private SimpleLocation parse(Cursor cursor, int index, boolean changed) { if (cursor.getDouble(index) != 0.d || cursor.getDouble(index + 1) != 0.d) { return SimpleLocation.builder().latitude(cursor.getDouble(index)).longitude(cursor.getDouble(index + 1)) .radius(Configuration.with(context).accessPointAssumedAccuracy()).changed(changed).build(); } else {/*from w w w. jav a2 s . co m*/ return null; } }
From source file:com.money.manager.ex.budget.BudgetAdapter.java
private double loadTotalFor(String where) { double total = 0; int year = getYearFromBudgetName(mBudgetName); where += " AND " + ViewMobileData.Year + "=" + Integer.toString(year); int month = getMonthFromBudgetName(mBudgetName); if (month != Constants.NOT_SET) { where += " AND " + ViewMobileData.Month + "=" + Integer.toString(month); }/*from w w w .ja va 2 s . c o m*/ try { String query = prepareQuery(where); Cursor cursor = databaseLazy.get().query(query); if (cursor == null) return 0; // add all the categories and subcategories together. while (cursor.moveToNext()) { total += cursor.getDouble(cursor.getColumnIndex("TOTAL")); } cursor.close(); } catch (IllegalStateException ise) { Timber.e(ise, "loading category total"); } return total; }
From source file:com.QuarkLabs.BTCeClient.UpdateWidgetsTask.java
@Override protected JSONObject doInBackground(Void... params) { Set<String> set = new HashSet<>(); JSONObject response = null;//from w w w .j a v a 2s.c om for (int x : mMap.keySet()) { set.add(mMap.get(x)); } try { response = App.getPairInfo(set.toArray(new String[set.size()])); response = response == null ? new JSONObject() : response; Context context = mContext.get(); if (context == null) { return null; } DBWorker dbWorker = DBWorker.getInstance(context); String[] columns = { "pair", "last" }; Cursor cursor = dbWorker.pullWidgetData(columns); Map<String, Double> values = new HashMap<>(); if (cursor.moveToFirst()) { while (!cursor.isAfterLast()) { values.put(cursor.getString(cursor.getColumnIndex(columns[0])), cursor.getDouble(cursor.getColumnIndex(columns[1]))); cursor.moveToNext(); } } cursor.close(); for (@SuppressWarnings("unchecked") Iterator<String> x = response.keys(); x.hasNext();) { String pair = x.next(); String pairInDB = pair.replace("_", "/").toUpperCase(Locale.US); ContentValues cv = new ContentValues(4); double last = response.getJSONObject(pair).getDouble("last"); double sell = response.getJSONObject(pair).getDouble("sell"); double buy = response.getJSONObject(pair).getDouble("buy"); cv.put("last", last); cv.put("buy", buy); cv.put("sell", sell); if (values.containsKey(pairInDB)) { if (last >= values.get(pairInDB)) { response.getJSONObject(pair).put("color", "green"); } else { response.getJSONObject(pair).put("color", "red"); } } else { response.getJSONObject(pair).put("color", "green"); } int result = dbWorker.updateWidgetData(cv, pair.replace("_", "/").toUpperCase(Locale.US)); if (result == 0) { cv.put("pair", pair.replace("_", "/").toUpperCase(Locale.US)); dbWorker.insertToWidgetData(cv); } } } catch (JSONException e) { e.printStackTrace(); } return response; }
From source file:fr.enst.igr201.kanmogne.iconvert.ConvertTabFragment.java
private double queryCurrencyTable(Uri uri) { Log.wtf(TAG, "URI : -> " + CurrencyContract.Currency.getCurrencyNameFromURI(uri)); double rate = 0.0; String[] projection = { CurrencyContract.Currency.COLUMN_RATE }; String selection = String.format("%s.%s = ?", CurrencyContract.Currency.TABLE_CURRENCY, CurrencyContract.Currency.COLUMN_NAME); // Log.wtf(TAG, "getNameFromURI : -> " + CurrencyContract.Currency.getCurrencyNameFromURI(uri)); String[] selectionArgs = { CurrencyContract.Currency.getCurrencyNameFromURI(uri) }; Cursor cursor = mResolver.query(uri, projection, selection, selectionArgs, null); try {//from ww w . j a v a2 s. c o m if (cursor.moveToFirst()) { int rateIndex = cursor.getColumnIndex(CurrencyContract.Currency.COLUMN_RATE); rate = cursor.getDouble(rateIndex); } } finally { cursor.close(); } // Log.wtf(TAG, "Rate : -->>" + rate); return rate; }