List of usage examples for android.provider BaseColumns _ID
String _ID
To view the source code for android.provider BaseColumns _ID.
Click Source Link
From source file:com.bydavy.card.receipts.ReceiptPagerAdapter.java
public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; }/* ww w. jav a 2s . c om*/ final Cursor oldCursor = mCursor; mCursor = newCursor; if (newCursor != null) { mRowIDColumn = newCursor.getColumnIndexOrThrow(BaseColumns._ID); mRowShopColumn = newCursor.getColumnIndexOrThrow(Receipts.COLUMN_NAME_SHOP); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetChanged(); } return oldCursor; }
From source file:com.espian.ticktock.AddEditActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_add: ContentValues cvs = new ContentValues(); String label = mTitle.getText().toString(); if (label == null || label.isEmpty()) { Toast.makeText(this, R.string.no_empty_label, Toast.LENGTH_SHORT).show(); return true; }//from www .j a v a2 s .co m cvs.put("label", label); cvs.put("date", DateFormat.getDateInstance(DateFormat.LONG).format(mDatePicker.getSelectedDate())); if (isEdit) { int updateResult = getContentResolver().update(TickTockProvider.countdownUri, cvs, BaseColumns._ID + "=?", new String[] { editId + "" }); if (updateResult == 1) { setResult(RESULT_OK); finish(); } else { Toast.makeText(this, getString(R.string.failed_update, mTitle.getText().toString()), Toast.LENGTH_SHORT).show(); } } else { Uri result = getContentResolver().insert(TickTockProvider.countdownUri, cvs); if (result != null) { setResult(RESULT_OK); finish(); } else { Toast.makeText(this, getString(R.string.failed_add, mTitle.getText().toString()), Toast.LENGTH_SHORT).show(); } } break; case R.id.menu_discard: setResult(RESULT_CANCELED); finish(); break; } return true; }
From source file:com.espian.ticktock.CountdownFragment.java
@Override public String getTitle() { if (mLabel == null || mLabel.isEmpty()) return getArguments().getString(BaseColumns._ID); return mLabel.toUpperCase(); }
From source file:com.feathercoin.wallet.feathercoin.ExchangeRatesProvider.java
@Override public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) { final long now = System.currentTimeMillis(); if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) { Map<String, ExchangeRate> newExchangeRates = getFeathercoinCharts(); if (exchangeRates == null && newExchangeRates == null) newExchangeRates = getBlockchainInfo(); if (newExchangeRates != null) { exchangeRates = newExchangeRates; lastUpdated = now;// ww w. j a v a2 s . c o m } } if (exchangeRates == null) return null; final MatrixCursor cursor = new MatrixCursor( new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE }); if (selection == null) { for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) { final ExchangeRate rate = entry.getValue(); cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } } else if (selection.equals(KEY_CURRENCY_CODE)) { final String code = selectionArgs[0]; final ExchangeRate rate = exchangeRates.get(code); try { cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } catch (NullPointerException e) { Log.e("Feathercoin", "Unable to add an exchange rate. NullPointerException."); } } return cursor; }
From source file:de.schildbach.wallet.elysium.ExchangeRatesProvider.java
@Override public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) { final long now = System.currentTimeMillis(); if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) { Map<String, ExchangeRate> newExchangeRates = getElysiumCharts(); if (exchangeRates == null && newExchangeRates == null) newExchangeRates = getBlockchainInfo(); if (newExchangeRates != null) { exchangeRates = newExchangeRates; lastUpdated = now;/*from w ww .j av a 2 s. c om*/ } } if (exchangeRates == null) return null; final MatrixCursor cursor = new MatrixCursor( new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE }); if (selection == null) { for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) { final ExchangeRate rate = entry.getValue(); cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } } else if (selection.equals(KEY_CURRENCY_CODE)) { final String code = selectionArgs[0]; final ExchangeRate rate = exchangeRates.get(code); try { cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } catch (NullPointerException e) { Log.e("Elysium", "Unable to add an exchange rate. NullPointerException."); } } return cursor; }
From source file:de.schildbach.wallet.marscoin.ExchangeRatesProvider.java
@Override public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) { final long now = System.currentTimeMillis(); if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) { Map<String, ExchangeRate> newExchangeRates = getmarscoinCharts(); if (exchangeRates == null && newExchangeRates == null) newExchangeRates = getBlockchainInfo(); if (newExchangeRates != null) { exchangeRates = newExchangeRates; lastUpdated = now;/* w ww . j a v a2s . c om*/ } } if (exchangeRates == null) return null; final MatrixCursor cursor = new MatrixCursor( new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE }); if (selection == null) { for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) { final ExchangeRate rate = entry.getValue(); cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } } else if (selection.equals(KEY_CURRENCY_CODE)) { final String code = selectionArgs[0]; final ExchangeRate rate = exchangeRates.get(code); try { cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } catch (NullPointerException e) { Log.e("marscoin", "Unable to add an exchange rate. NullPointerException."); } } return cursor; }
From source file:com.google.android.demos.jamendo.app.SearchActivity.java
/** {@inheritDoc} */ public Loader<Cursor> onCreateLoader(int id, Bundle args) { Intent intent = getIntent();/*w ww .j ava 2 s .co m*/ String query = intent.getStringExtra(SearchManager.QUERY); Uri.Builder builder = JamendoContract.AUTHORITY_URI.buildUpon(); builder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY); builder.appendPath(query); Uri uri = builder.build(); String[] projection = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_ICON_2, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_TEXT_2 }; String selection = JamendoContract.PARAM_IMAGE_SIZE + "=" + mImageSize; String[] selectionArgs = null; String sortOrder = null; return new CursorLoader(this, uri, projection, selection, selectionArgs, sortOrder); }
From source file:com.fabernovel.alertevoirie.data.CategoryProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { JSONArray array = new JSONArray(); try {//from ww w. j ava2 s. com String categoryId = JsonData.VALUE_NULL; switch (uriMatcher.match(uri)) { case CATEGORIES_ID: categoryId = uri.getLastPathSegment(); //$FALL-THROUGH$ case CATEGORIES: JSONObject parent = categories.getJSONObject(categoryId); if (parent.has(JsonData.PARAM_CATEGORY_CHILDREN)) { JSONArray subset = parent.getJSONArray(JsonData.PARAM_CATEGORY_CHILDREN); for (int i = 0; i < subset.length(); i++) { JSONObject obj = categories.getJSONObject(subset.getString(i)); obj.put(BaseColumns._ID, (long) Integer.valueOf(subset.getString(i))); array.put(obj); } } break; case CATEGORY_ID: categoryId = uri.getLastPathSegment(); array.put(categories.getJSONObject(categoryId)); Log.d(Constants.PROJECT_TAG, "category returned = " + categories.getJSONObject(categoryId)); break; default: return null; } } catch (NumberFormatException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } Cursor c = new JSONCursor(array, projection); if (c != null) c.setNotificationUri(getContext().getContentResolver(), uri); return c; }
From source file:org.cnx.android.quizcards.activities.CardListActivity.java
private void getCards() { String[] projection = { BaseColumns._ID, DECK_ID, TERM, MEANING }; String selection = DECK_ID + " = '" + id + "'"; String order = "LOWER(" + TERM + ")"; //SQLite normally orders any upper case before all lower case cardsCursor = getContentResolver().query(CardProvider.CONTENT_URI, projection, selection, null, order); if (cardsCursor != null) { cardsCursor.moveToFirst();//from w ww .j a v a 2s. c om } int[] to = { R.id.term, R.id.meaning }; String[] from = { TERM, MEANING }; cursorAdapter = new SimpleCursorAdapter(this, R.layout.card_list_row, cardsCursor, from, to, CursorAdapter.NO_SELECTION); cardListView.setAdapter(cursorAdapter); }
From source file:de.schildbach.wallet.worldcoin.ExchangeRatesProvider.java
@Override public Cursor query(final Uri uri, final String[] projection, final String selection, final String[] selectionArgs, final String sortOrder) { final long now = System.currentTimeMillis(); if (exchangeRates == null || now - lastUpdated > UPDATE_FREQ_MS) { Map<String, ExchangeRate> newExchangeRates = getworldcoinCharts(); if (exchangeRates == null && newExchangeRates == null) newExchangeRates = getBlockchainInfo(); if (newExchangeRates != null) { exchangeRates = newExchangeRates; lastUpdated = now;//from w ww . j a v a 2 s. c om } } if (exchangeRates == null) return null; final MatrixCursor cursor = new MatrixCursor( new String[] { BaseColumns._ID, KEY_CURRENCY_CODE, KEY_RATE, KEY_SOURCE }); if (selection == null) { for (final Map.Entry<String, ExchangeRate> entry : exchangeRates.entrySet()) { final ExchangeRate rate = entry.getValue(); cursor.newRow().add(entry.getKey().hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } } else if (selection.equals(KEY_CURRENCY_CODE)) { final String code = selectionArgs[0]; final ExchangeRate rate = exchangeRates.get(code); try { cursor.newRow().add(code.hashCode()).add(rate.currencyCode).add(rate.rate.longValue()) .add(rate.source); } catch (NullPointerException e) { Log.e("worldcoin", "Unable to add an exchange rate. NullPointerException."); } } return cursor; }