List of usage examples for android.database Cursor getString
String getString(int columnIndex);
From source file:DictionaryAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setText(cursor.getString(getCursor().getColumnIndex("word"))); }
From source file:de.luhmer.owncloudnewsreader.reader.GoogleReaderApi.GoogleReaderMethods.java
public static void MarkItemAsStarred(Boolean isStarred, Cursor cursor, DatabaseConnection dbConn, Context context, OnAsyncTaskCompletedListener asyncTaskCompletedPerformTagStarred) { List<NameValuePair> nameValuePairs = getStarredReadNameValuePairs(dbConn, cursor); if (isStarred) nameValuePairs.add(new BasicNameValuePair("a", GoogleReaderConstants._STATE_STARRED)); else// w w w. j a v a 2 s . com nameValuePairs.add(new BasicNameValuePair("r", GoogleReaderConstants._STATE_STARRED)); ExecuteTagsReadStarred(nameValuePairs, context, asyncTaskCompletedPerformTagStarred); Log.d("CHECKBOX", "STARRED CHANGED: " + isStarred); dbConn.updateIsStarredOfItem(cursor.getString(0), isStarred); }
From source file:mil.nga.giat.mage.sdk.utils.MediaUtility.java
public static String getFileAbsolutePath(Uri uri, Context c) { String fileName = null;/*from w ww . j a v a 2s. com*/ String scheme = uri.getScheme(); if (scheme.equals("file")) { fileName = uri.getPath(); } else if (scheme.equals("content")) { Cursor cursor = null; try { String[] proj = { MediaStore.Images.Media.DATA }; cursor = c.getContentResolver().query(uri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } catch (Exception e) { Log.e(LOG_NAME, "Error reading content URI", e); } finally { if (cursor != null) { cursor.close(); } } } return fileName; }
From source file:com.frostwire.android.gui.views.SuggestionsAdapter.java
@Override public CharSequence convertToString(Cursor cursor) { if (cursor != null) { return cursor.getString(1); }/*from w ww .j a v a2 s. c om*/ return null; }
From source file:com.haoqee.chatsdk.net.Utility.java
/** * Get a HttpClient object which is setting correctly . * // w w w. j av a 2 s .c o m * @param context * : context of activity * @return HttpClient: HttpClient object */ public static DefaultHttpClient getHttpClient(Context context) { BasicHttpParams httpParameters = new BasicHttpParams(); // Set the default socket timeout (SO_TIMEOUT) // in // milliseconds which is the timeout for waiting for data. HttpConnectionParams.setConnectionTimeout(httpParameters, Utility.SET_CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(httpParameters, Utility.SET_SOCKET_TIMEOUT); DefaultHttpClient client = new DefaultHttpClient(httpParameters); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { // ??PN???? Uri uri = Uri.parse("content://telephony/carriers/preferapn"); Cursor mCursor = context.getContentResolver().query(uri, null, null, null, null); if (mCursor != null && mCursor.moveToFirst()) { // ?????? String proxyStr = mCursor.getString(mCursor.getColumnIndex("proxy")); if (proxyStr != null && proxyStr.trim().length() > 0) { HttpHost proxy = new HttpHost(proxyStr, 80); client.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy); } mCursor.close(); } } return client; }
From source file:com.manning.androidhacks.hack043.adapter.BatchAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder holder = (ViewHolder) view.getTag(); holder.id.setText(cursor.getString(mIdIndex)); holder.number.setText(cursor.getString(mNumberIndex)); }
From source file:com.pheromone.plugins.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 ctx the current applicaiton context * @return the full path to the file//from ww w .ja v a2 s.c o m */ protected static String getRealPathFromURI(Uri contentUri, PhonegapActivity ctx) { String[] proj = { _DATA }; Cursor cursor = ctx.managedQuery(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(_DATA); cursor.moveToFirst(); return cursor.getString(column_index); }
From source file:cn.code.notes.gtask.data.SqlConn.java
private void loadFromCursor(Cursor c) { mGuid = c.getString(GUID_COLUMN); mId = c.getLong(ID_COLUMN); mDataMD5 = c.getString(MD5_COLUMN); }
From source file:mil.nga.giat.mage.sdk.utils.MediaUtility.java
/** * Get display name from the uri/*from w w w. j av a2 s.c o m*/ * * @param context * @param uri * @return */ @TargetApi(Build.VERSION_CODES.KITKAT) public static String getDisplayName(Context context, Uri uri) { String name = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ContentResolver resolver = context.getContentResolver(); Cursor nameCursor = resolver.query(uri, null, null, null, null); try { if (nameCursor.getCount() > 0) { int displayNameIndex = nameCursor .getColumnIndex(DocumentsContract.Document.COLUMN_DISPLAY_NAME); if (displayNameIndex >= 0 && nameCursor.moveToFirst()) { name = nameCursor.getString(displayNameIndex); } } } finally { nameCursor.close(); } } return name; }
From source file:mil.nga.giat.mage.sdk.utils.MediaUtility.java
/** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context./* w ww . j a va 2s. c o m*/ * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. */ public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { Cursor cursor = null; final String column = "_data"; final String[] projection = { column }; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { final int column_index = cursor.getColumnIndexOrThrow(column); return cursor.getString(column_index); } } catch (Exception e) { Log.e(LOG_NAME, "Error getting data column", e); } finally { if (cursor != null) cursor.close(); } return null; }