List of usage examples for android.database Cursor getColumnIndexOrThrow
int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException;
From source file:co.mwater.foregroundcameraplugin.ForegroundCameraLauncher.java
/** * Queries the media store to find out what the file path is for the Uri we * supply// ww w . j a v a 2 s . co m * * @param contentUri * the Uri of the audio/image/video * @param ctx * the current applicaiton context * @return the full path to the file */ private String getRealPathFromURI(Uri contentUri, CordovaInterface ctx) { String[] proj = { _DATA }; Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(_DATA); cursor.moveToFirst(); return cursor.getString(column_index); }
From source file:fi.mikuz.boarder.gui.internet.Login.java
private String getDbPassword() { String dbPassword = null;/* ww w. j a va 2 s. co m*/ try { Cursor loginCursor = mDbHelper.fetchLogin(InternetMenu.PASSWORD_KEY); startManagingCursor(loginCursor); dbPassword = loginCursor.getString(loginCursor.getColumnIndexOrThrow(LoginDbAdapter.KEY_DATA)); } catch (SQLException e) { Log.d(TAG, "Couldn't get database login info", e); } catch (CursorIndexOutOfBoundsException e) { Log.d(TAG, "Couldn't get database login info", e); } return dbPassword; }
From source file:edu.stanford.mobisocial.dungbeetle.model.DbObject.java
/** * Use SocialKit Obj implementations./*w ww . ja v a2 s . c om*/ */ @Deprecated private DbObject(Cursor c) { mType = c.getString(c.getColumnIndexOrThrow(DbObject.TYPE)); String jsonStr = c.getString(c.getColumnIndexOrThrow(DbObject.JSON)); try { mRaw = c.getBlob(c.getColumnIndexOrThrow(DbObject.RAW)); } catch (IllegalArgumentException e) { mRaw = null; } try { mJson = new JSONObject(jsonStr); } catch (JSONException e) { Log.wtf("DB", "Bad json from database."); } //mTimestamp = c.getLong(c.getColumnIndexOrThrow(DbObject.TIMESTAMP)); }
From source file:com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountAdapter.java
@Override protected Cursor getChildrenCursor(Cursor groupCursor) { int accountColumn = groupCursor.getColumnIndexOrThrow(Calendars.ACCOUNT_NAME); int accountTypeColumn = groupCursor.getColumnIndexOrThrow(Calendars.ACCOUNT_TYPE); String account = groupCursor.getString(accountColumn); String accountType = groupCursor.getString(accountTypeColumn); //Get all the calendars for just this account. Cursor childCursor = mChildrenCursors.get(accountType + "#" + account); new RefreshCalendars(groupCursor.getPosition(), account, accountType).run(); return childCursor; }
From source file:cc.solart.turbo.BaseCursorAdapter.java
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed.//from w w w. ja v a 2 s .c o m * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there was not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; mCursor = newCursor; if (newCursor != null) { mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); 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(); // notifyItemRangeRemoved(0, oldCursor.getCount() - 1); } return oldCursor; }
From source file:edu.stanford.mobisocial.dungbeetle.DBIdentityProvider.java
public DBIdentityProvider(DBHelper helper) { mHelper = helper;//from w ww . ja v a 2 s.c o m helper.addRef(); mUnclosedException = new Exception("Finalized without close being called. Created at..."); Cursor c = mHelper.getReadableDatabase().rawQuery("SELECT * FROM " + MyInfo.TABLE, new String[] {}); try { if (!c.moveToFirst()) { throw new IllegalStateException("Missing my_info entry!"); } mPubKeyString = c.getString(c.getColumnIndexOrThrow(MyInfo.PUBLIC_KEY)); mPubKey = RSACrypto.publicKeyFromString(mPubKeyString); mPrivKey = RSACrypto.privateKeyFromString(c.getString(c.getColumnIndexOrThrow(MyInfo.PRIVATE_KEY))); mName = c.getString(c.getColumnIndexOrThrow(MyInfo.NAME)); mEmail = c.getString(c.getColumnIndexOrThrow(MyInfo.EMAIL)); mPubKeyTag = personIdForPublicKey(mPubKey); Log.d(TAG, c.getCount() + " public keys"); } finally { c.close(); } }
From source file:cc.mintcoin.wallet.ui.SendingAddressesFragment.java
@Override public void onListItemClick(final ListView l, final View v, final int position, final long id) { activity.startActionMode(new ActionMode.Callback() { @Override//from w w w. j av a2 s .c o m public boolean onCreateActionMode(final ActionMode mode, final Menu menu) { final MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.sending_addresses_context, menu); return true; } @Override public boolean onPrepareActionMode(final ActionMode mode, final Menu menu) { final String label = getLabel(position); mode.setTitle(label); return true; } @Override public boolean onActionItemClicked(final ActionMode mode, final MenuItem item) { switch (item.getItemId()) { case R.id.sending_addresses_context_send: handleSend(getAddress(position)); mode.finish(); return true; case R.id.sending_addresses_context_edit: EditAddressBookEntryFragment.edit(getFragmentManager(), getAddress(position)); mode.finish(); return true; case R.id.sending_addresses_context_remove: handleRemove(getAddress(position)); mode.finish(); return true; case R.id.sending_addresses_context_show_qr: handleShowQr(getAddress(position)); mode.finish(); return true; case R.id.sending_addresses_context_copy_to_clipboard: handleCopyToClipboard(getAddress(position)); mode.finish(); return true; } return false; } @Override public void onDestroyActionMode(final ActionMode mode) { } private String getAddress(final int position) { final Cursor cursor = (Cursor) adapter.getItem(position); return cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_ADDRESS)); } private String getLabel(final int position) { final Cursor cursor = (Cursor) adapter.getItem(position); return cursor.getString(cursor.getColumnIndexOrThrow(AddressBookProvider.KEY_LABEL)); } }); }
From source file:com.example.android.wardrobe.HomeActivity.java
public String getRealPathFromURI(Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst();//from ww w.j av a 2 s . co m return cursor.getString(column_index); }
From source file:com.android.calendar.selectcalendars.SelectSyncedCalendarsMultiAccountAdapter.java
@Override protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) { int accountColumn = cursor.getColumnIndexOrThrow(Calendars.ACCOUNT_NAME); int accountTypeColumn = cursor.getColumnIndexOrThrow(Calendars.ACCOUNT_TYPE); String account = cursor.getString(accountColumn); String accountType = cursor.getString(accountTypeColumn); CharSequence accountLabel = getLabelForType(accountType); setText(view, R.id.account, account); if (accountLabel != null) { setText(view, R.id.account_type, accountLabel.toString()); }/* w ww . j a va 2 s. com*/ }
From source file:com.googlecode.android_scripting.facade.ContactsFacade.java
@Rpc(description = "Displays a list of phone numbers to pick from.", returns = "The selected phone number.") public String pickPhone() throws JSONException { String result = null;//from ww w.j a v a 2s. c o m Intent data = mCommonIntentsFacade.pick("content://contacts/phones"); if (data != null) { Uri phoneData = data.getData(); Cursor cursor = mService.getContentResolver().query(phoneData, null, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { result = cursor.getString(cursor.getColumnIndexOrThrow(PhonesColumns.NUMBER)); } cursor.close(); } } return result; }