List of usage examples for android.database Cursor getColumnIndexOrThrow
int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException;
From source file:com.chatwingsdk.fragments.ConversationsFragment.java
@Override protected void handleItemClick(Cursor cursor) { int columnConversationIndex = cursor.getColumnIndexOrThrow(ConversationTable.CONVERSATION_ID); String conversationId = cursor.getString(columnConversationIndex); mBus.post(new UserSelectedConversationEvent(conversationId)); }
From source file:com.pdftron.pdf.utils.Utils.java
public static String getUriDisplayName(Context context, Uri contentUri) { String displayName = null;/* w w w . j av a 2 s.c o m*/ String[] projection = { OpenableColumns.DISPLAY_NAME }; Cursor cursor = null; if (contentUri.getScheme().equalsIgnoreCase("file")) { return contentUri.getLastPathSegment(); } try { cursor = context.getContentResolver().query(contentUri, projection, null, null, null); if (cursor != null && cursor.moveToFirst()) { int nameIndex = cursor.getColumnIndexOrThrow(projection[0]); if (nameIndex >= 0) { displayName = cursor.getString(nameIndex); } } } catch (Exception e) { displayName = null; } if (cursor != null) { cursor.close(); } return displayName; }
From source file:com.google.android.demos.jamendo.widget.TrackListAdapter.java
private void bindTrackDuration(View view, Cursor cursor) { long duration = cursor.getLong(cursor.getColumnIndexOrThrow(Tracks.DURATION)); mDate.setTime(duration * 1000);/*ww w . j av a2 s . c om*/ String formatted = mFormat.format(mDate); TextView textView = (TextView) view.findViewById(R.id.jamendo_track_duration); textView.setText(formatted); }
From source file:com.MustacheMonitor.MustacheMonitor.FileUtils.java
/** * Queries the media store to find out what the file path is for the Uri we supply * * @param contentUri the Uri of the audio/image/video * @param cordova) the current applicaiton context * @return the full path to the file//ww w. j ava 2 s . co m */ @SuppressWarnings("deprecation") protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) { 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:com.google.android.demos.jamendo.widget.TrackListAdapter.java
private void bindTrackName(View view, Cursor cursor) { String trackName = cursor.getString(cursor.getColumnIndexOrThrow(Tracks.NAME)); TextView textView = (TextView) view.findViewById(R.id.jamendo_track_name); textView.setText(trackName);//ww w .j av a2 s . co m }
From source file:com.chatwing.whitelabel.fragments.CategoriesFragment.java
@Override public void onChildClicked(Cursor childCursor) { int idIndex = childCursor.getColumnIndexOrThrow(ChatBoxTable._ID); mBus.post(new UserSelectedChatBoxEvent(childCursor.getInt(idIndex))); }
From source file:com.manning.androidhacks.hack023.adapter.TodoAdapter.java
public TodoAdapter(Activity activity) { super(activity, getManagedCursor(activity), true); mActivity = activity;/* w w w . j a v a 2 s. co m*/ mInflater = LayoutInflater.from(activity); final Cursor c = getCursor(); mInternalIdIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_ID); mTitleIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_TITLE); mInternalStatusIndex = c.getColumnIndexOrThrow(TodoContentProvider.COLUMN_STATUS_FLAG); }
From source file:com.manning.androidhacks.hack043.adapter.BatchAdapter.java
public BatchAdapter(Context context, Cursor c) { super(context, c, true); mInflater = LayoutInflater.from(context); mIdIndex = c.getColumnIndexOrThrow(BatchNumbersContentProvider.COLUMN_ID); mNumberIndex = c.getColumnIndexOrThrow(BatchNumbersContentProvider.COLUMN_TEXT); }
From source file:com.manning.androidhacks.hack043.adapter.NoBatchAdapter.java
public NoBatchAdapter(Context context, Cursor c) { super(context, c, true); mInflater = LayoutInflater.from(context); mIdIndex = c.getColumnIndexOrThrow(NoBatchNumbersContentProvider.COLUMN_ID); mNumberIndex = c.getColumnIndexOrThrow(NoBatchNumbersContentProvider.COLUMN_TEXT); }
From source file:com.manning.androidhacks.hack043.adapter.SQLContentProviderAdapter.java
public SQLContentProviderAdapter(Context context, Cursor c) { super(context, c, true); mInflater = LayoutInflater.from(context); mIdIndex = c.getColumnIndexOrThrow(MySQLContentProvider.COLUMN_ID); mNumberIndex = c.getColumnIndexOrThrow(MySQLContentProvider.COLUMN_TEXT); }