List of usage examples for android.content ContentValues getAsLong
public Long getAsLong(String key)
From source file:br.com.scalasoft.alvaro.weather.FetchWeatherTask.java
String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) { // return strings to keep UI functional for now String[] resultStrs = new String[cvv.size()]; for (int i = 0; i < cvv.size(); i++) { ContentValues weatherValues = cvv.elementAt(i); String highAndLow = formatHighLows(weatherValues.getAsDouble(WeatherEntry.COLUMN_MAX_TEMP), weatherValues.getAsDouble(WeatherEntry.COLUMN_MIN_TEMP)); resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherEntry.COLUMN_DATE)) + " - " + weatherValues.getAsString(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC) + " - " + highAndLow;// w w w. j a v a 2 s . com } return resultStrs; }
From source file:com.example.android.sunshine.data.FetchWeatherTask.java
String[] convertContentValuesToUXFormat(Vector<ContentValues> cvv) { // return strings to keep UI functional for now String[] resultStrs = new String[cvv.size()]; for (int i = 0; i < cvv.size(); i++) { ContentValues weatherValues = cvv.elementAt(i); String highAndLow = formatHighLows( weatherValues.getAsDouble(WeatherContract.WeatherEntry.COLUMN_MAX_TEMP), weatherValues.getAsDouble(WeatherContract.WeatherEntry.COLUMN_MIN_TEMP)); resultStrs[i] = getReadableDateString(weatherValues.getAsLong(WeatherContract.WeatherEntry.COLUMN_DATE)) + " - " + weatherValues.getAsString(WeatherContract.WeatherEntry.COLUMN_SHORT_DESC) + " - " + highAndLow;// w ww . ja v a 2s . c o m } return resultStrs; }
From source file:com.csipsimple.utils.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); try {/* w w w. j ava 2 s . c o m*/ for (int i = 0; i < names.length; i++) { if (!cv.containsKey(names[i])) { continue; } switch (types[i]) { case STRING: json.put(names[i], cv.getAsString(names[i])); break; case INT: json.put(names[i], cv.getAsInteger(names[i])); break; case LONG: json.put(names[i], cv.getAsLong(names[i])); break; case FLOAT: json.put(names[i], cv.getAsFloat(names[i])); break; case DOUBLE: json.put(names[i], cv.getAsDouble(names[i])); break; case BOOLEAN: json.put(names[i], cv.getAsBoolean(names[i])); break; } } } catch (JSONException e) { throw new RuntimeException(e); } return json; }
From source file:gxu.software_engineering.market.android.activity.NewItemActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish();//from ww w .j a va 2 s . c o m break; case R.id.discard: finish(); break; case R.id.done: Toast.makeText(this, R.string.submit, Toast.LENGTH_SHORT).show(); Log.i("null???", String.format("%s", this.name == null)); String[] data = resolveData(); try { long uid = MarketApp.marketApp().getPrefs().getLong(C.UID, -1); ContentValues values = new PostToCloud() .execute(cid + "", uid + "", data[0], data[1], data[2], data[3]).get(); Log.i("items>>>", values.toString()); getContentResolver().insert(Uri.parse(C.BASE_URI + C.ITEMS), values); Toast.makeText(this, R.string.publish_ok, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(this, ItemActivity.class); intent.putExtra(C.ID, values.getAsLong(C._ID)); startActivity(intent); } catch (Exception e) { Log.wtf("receive result error!", e); Toast.makeText(this, R.string.publish_fail, Toast.LENGTH_SHORT).show(); } break; default: break; } return false; }
From source file:export.GooglePlus.java
@Override public void init(ContentValues config) { String authConfig = config.getAsString(DB.ACCOUNT.AUTH_CONFIG); if (authConfig != null) { try {// www.j a va2s. co m JSONObject tmp = new JSONObject(authConfig); access_token = tmp.optString("access_token", null); refresh_token = tmp.optString("refresh_token", null); token_now = tmp.optLong("token_now"); expire_time = tmp.optLong("expire_time"); } catch (Exception e) { e.printStackTrace(); } } id = config.getAsLong("_id"); }
From source file:org.runnerup.export.RunKeeperSynchronizer.java
@Override public void init(ContentValues config) { String authConfig = config.getAsString(DB.ACCOUNT.AUTH_CONFIG); id = config.getAsLong("_id"); if (authConfig != null) { try {// w w w.j a va 2 s . c o m JSONObject tmp = new JSONObject(authConfig); access_token = tmp.optString("access_token", null); feed_access_token = tmp.optString("feed_access_token", null); if (feed_access_token == null) { feed_username = tmp.optString("username", null); feed_password = tmp.optString("password", null); } else { feed_username = null; feed_password = null; } } catch (Exception e) { Log.e(Constants.LOG, e.getMessage()); } } }
From source file:com.csipsimple.backup.Columns.java
public JSONObject contentValueToJSON(ContentValues cv) { JSONObject json = new JSONObject(); for (int i = 0; i < names.size(); i++) { if (!cv.containsKey(names.get(i))) { continue; }/*ww w . j av a 2s . com*/ try { String name = names.get(i); switch (types.get(i)) { case STRING: json.put(name, cv.getAsString(name)); break; case INT: json.put(name, cv.getAsInteger(name)); break; case LONG: json.put(name, cv.getAsLong(name)); break; case FLOAT: json.put(name, cv.getAsFloat(name)); break; case DOUBLE: json.put(name, cv.getAsDouble(name)); break; case BOOLEAN: json.put(name, cv.getAsBoolean(name)); break; default: Log.w("Col", "Invalid type, can't unserialize " + types.get(i)); } } catch (JSONException e) { Log.e("Col", "Invalid type, can't unserialize ", e); } } return json; }
From source file:org.runnerup.gpstracker.GpsTracker.java
public void newLap(ContentValues tmp) { tmp.put(DB.LAP.ACTIVITY, mActivityId); mLapId = mDB.insert(DB.LAP.TABLE, null, tmp); ContentValues key = mDBWriter.getKey(); key.put(DB.LOCATION.LAP, tmp.getAsLong(DB.LAP.LAP)); mDBWriter.setKey(key);//from w w w .j a va 2 s .c o m }
From source file:org.runnerup.export.FacebookSynchronizer.java
@Override public void init(ContentValues config) { String authConfig = config.getAsString(DB.ACCOUNT.AUTH_CONFIG); if (authConfig != null) { try {/*from w ww.j a va 2 s . c o m*/ JSONObject tmp = new JSONObject(authConfig); access_token = tmp.optString("access_token", null); token_now = tmp.optLong("token_now"); expire_time = tmp.optLong("expire_time"); } catch (Exception e) { e.printStackTrace(); } } id = config.getAsLong("_id"); if (config.containsKey(DB.ACCOUNT.FLAGS)) { long flags = config.getAsLong(DB.ACCOUNT.FLAGS); if (Bitfield.test(flags, DB.ACCOUNT.FLAG_SKIP_MAP)) { skipMapInPost = true; } } }
From source file:net.sf.diningout.content.SyncAdapter.java
/** * Sync remote changes to a review draft. *///from www .j av a 2 s . co m private void syncReviewDraft(ContentProviderClient cp, Sync<Review> sync) throws RemoteException { ContentValues vals = ReviewDrafts.values(sync.object); /* get current version and increment it */ Uri uri = ContentUris.withAppendedId(REVIEW_DRAFTS_URI, vals.getAsLong(ReviewDrafts.RESTAURANT_ID)); String[] proj = { ReviewDrafts.VERSION }; long version = Cursors.firstLong(cp.query(uri, proj, null, null, null)); if (version >= 0) { vals.put(ReviewDrafts.VERSION, version + 1); cp.update(uri, vals, null, null); } else { cp.insert(REVIEW_DRAFTS_URI, vals); } }