List of usage examples for android.database Cursor getString
String getString(int columnIndex);
From source file:Main.java
public static String getThumbnailPathForLocalFile(Context context, Uri fileUri) { long fileId = getFileId(context, fileUri); MediaStore.Video.Thumbnails.getThumbnail(context.getContentResolver(), fileId, MediaStore.Video.Thumbnails.MICRO_KIND, null); Cursor thumbCursor = null; try {/* ww w .j a v a 2 s . c o m*/ thumbCursor = context.getContentResolver().query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, thumbColumns, MediaStore.Video.Thumbnails.VIDEO_ID + " = " + fileId, null, null); if (thumbCursor.moveToFirst()) { String thumbPath = thumbCursor .getString(thumbCursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA)); return thumbPath; } } finally { } return null; }
From source file:net.lamp.support.NetStateManager.java
/** * ?? APN ?{@link HttpHost} /*ww w .j a v a 2 s .co m*/ * * @return {@link HttpHost} */ public static HttpHost getAPN() { HttpHost proxy = null; Uri uri = Uri.parse("content://telephony/carriers/preferapn"); Cursor mCursor = null; if (null != mContext) { mCursor = mContext.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) { proxy = new HttpHost(proxyStr, 80); } mCursor.close(); } return proxy; }
From source file:Main.java
public static String getLatestImage(Activity context) { String latestImage = null;/*from w w w .ja v a 2 s .c om*/ String[] items = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA }; Cursor cursor = context.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, items, null, null, MediaStore.Images.Media._ID + " desc"); if (cursor != null && cursor.getCount() > 0) { cursor.moveToFirst(); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { latestImage = cursor.getString(1); break; } } return latestImage; }
From source file:Main.java
public static String loadString(String key, String defaultVal, SQLiteDatabase db) { String ret = defaultVal;//from w ww. j a v a2 s .c o m if (db == null) return ret; Cursor cursor = db.query(TABLE_SETTINGS, new String[] { KEY_SETTINGS_ID, KEY_SETTINGS_KEY, KEY_SETTINGS_VALUE }, KEY_SETTINGS_KEY + "=?", new String[] { key }, null, null, null, null); if (cursor != null) { boolean moveFirst = cursor.moveToFirst(); if (moveFirst) ret = cursor.getString(2); } return ret; }
From source file:cn.edu.wyu.documentviewer.model.DocumentInfo.java
public static String getCursorString(Cursor cursor, String columnName) { final int index = cursor.getColumnIndex(columnName); return (index != -1) ? cursor.getString(index) : null; }
From source file:Main.java
public static String getFilePathByContentResolver(Context context, Uri uri) { if (null == uri) { return null; }/*from ww w.j av a2s. c o m*/ Cursor c = context.getContentResolver().query(uri, null, null, null, null); String filePath = null; if (null == c) { throw new IllegalArgumentException("Query on " + uri + " returns null result."); } try { if ((c.getCount() != 1) || !c.moveToFirst()) { } else { filePath = c.getString(c.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA)); } } finally { c.close(); } return filePath; }
From source file:Main.java
private static String getRealPathFromURI(Context context, Uri contentURI) { String result;/*from ww w . j a va 2 s . c o m*/ Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file path result = contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); result = cursor.getString(idx); cursor.close(); } return result; }
From source file:Main.java
public static String getRealPathFromURI(Context context, Uri contentUri) { Cursor cursor = null; try {//from w ww. j a va 2 s . co m String[] proj = { MediaStore.Images.Media.DATA }; cursor = context.getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } catch (NullPointerException ex) { return ""; } finally { if (cursor != null) { cursor.close(); } } }
From source file:Main.java
public static String getRealFilePath(Context context, Uri uri) { if (null == uri) return null; String scheme = uri.getScheme(); String data = null;/*from w w w .ja v a2 s. c om*/ if (scheme == null) data = uri.getPath(); else if (ContentResolver.SCHEME_FILE.equals(scheme)) { data = uri.getPath(); } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) { Cursor cursor = context.getContentResolver().query(uri, new String[] { ImageColumns.DATA }, null, null, null); if (null != cursor) { if (cursor.moveToFirst()) { int index = cursor.getColumnIndex(ImageColumns.DATA); if (index > -1) { data = cursor.getString(index); } } cursor.close(); } } return data; }
From source file:net.peterkuterna.android.apps.devoxxsched.util.SyncUtils.java
public static String getLocalMd5(ContentResolver resolver, String url) { final String syncId = Sync.generateSyncId(url); final Uri uri = Sync.buildSyncUri(syncId); Cursor cursor = resolver.query(uri, SyncQuery.PROJECTION, null, null, null); try {/*w w w . j a v a2 s . co m*/ if (!cursor.moveToFirst()) return ""; return cursor.getString(SyncQuery.MD5); } finally { cursor.close(); } }