當前位置: 首頁>>代碼示例>>Java>>正文


Java OpenableColumns類代碼示例

本文整理匯總了Java中android.provider.OpenableColumns的典型用法代碼示例。如果您正苦於以下問題:Java OpenableColumns類的具體用法?Java OpenableColumns怎麽用?Java OpenableColumns使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OpenableColumns類屬於android.provider包,在下文中一共展示了OpenableColumns類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
private String getFileName(Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } finally {
            cursor.close();
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:jinseongho,項目名稱:lottie_for_designer,代碼行數:22,代碼來源:MainActivity.java

示例2: getContentSize

import android.provider.OpenableColumns; //導入依賴的package包/類
public static long getContentSize(final Uri contentUri) {
    Cursor cursor = null;
    try {
        cursor = FacebookSdk
                .getApplicationContext()
                .getContentResolver()
                .query(contentUri, null, null, null, null);
        int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);

        cursor.moveToFirst();
        return cursor.getLong(sizeIndex);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:18,代碼來源:Utility.java

示例3: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
/**
 * 根據uri獲取文件路徑
 * @param context
 * @param uri
 * @return
 */
static String getFileName(Context context, Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf(File.separator);
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:32,代碼來源:FileUtil.java

示例4: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
public static String getFileName(Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = null;
        try {
            cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null);
            if (cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:27,代碼來源:MediaController.java

示例5: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
protected String getFileName(Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } finally {
            cursor.close();
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:mo3rfan,項目名稱:syncplayer,代碼行數:22,代碼來源:videoPlayer.java

示例6: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
static String getFileName(Context context, Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf(File.separator);
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:26,代碼來源:FileUtil.java

示例7: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
public String getFileName(Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getLastPathSegment();
    }
    return result;
}
 
開發者ID:barteksc,項目名稱:AndroidPdfViewerV2,代碼行數:20,代碼來源:PDFViewActivity.java

示例8: loadFromUri

import android.provider.OpenableColumns; //導入依賴的package包/類
@Override
public void loadFromUri(Context context, Uri fileUri) {
    try {
        InputStream in =
                context.getContentResolver().openInputStream(fileUri);
        if (fileUri.getScheme().equals("content")) {
            Cursor retCur = context.getContentResolver()
                    .query(fileUri, null, null, null, null);
            if (retCur != null) {
                int nameIndex = retCur
                        .getColumnIndex(OpenableColumns.DISPLAY_NAME);
                retCur.moveToFirst();
                setFileName(retCur.getString(nameIndex));
            }
        } else if (fileUri.getScheme().equals("file")) {
            setFileName(fileUri.getLastPathSegment());
        }
        loadMarkdown(in);
    } catch (Exception e) {
        if (editView != null)
            editView.showFileLoadeddError(MarkdownFile.READ_ERROR);
    }
}
 
開發者ID:wbrawner,項目名稱:SimpleMarkdown,代碼行數:24,代碼來源:MarkdownPresenterImpl.java

示例9: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
public String getFileName(Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = mCR.query(uri, null, null, null, null);
        try {
            if (cursor != null && cursor.moveToFirst()) {
                result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:gimportexportdevs,項目名稱:gexporter,代碼行數:24,代碼來源:MainActivity.java

示例10: getFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
public String getFileName(Uri uri) {
  String result = null;
  if (uri.getScheme().equals("content")) {
    Cursor cursor = getContentResolver().query(uri, null, null, null, null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
      }
    } finally {
      cursor.close();
    }
  }
  if (result == null) {
    result = uri.getPath();
    int cut = result.lastIndexOf('/');
    if (cut != -1) {
      result = result.substring(cut + 1);
    }
  }
  return result;
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:22,代碼來源:EDVolumeListActivity.java

示例11: retrieveFileName

import android.provider.OpenableColumns; //導入依賴的package包/類
public static String retrieveFileName(Context context, Uri uri) {
    //retrieve file name
    try {
        Cursor cursor = context.getContentResolver().query(uri,
                new String[]{OpenableColumns.DISPLAY_NAME},
                null, null, null);
        if (cursor != null) {
            int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
            cursor.moveToFirst();
            if (!cursor.isAfterLast()) {
                String filename = cursor.getString(nameIndex);
                cursor.close();
                return filename;
            }
        }
    } catch (SecurityException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:21,代碼來源:InfoUtil.java

示例12: retrieveFileSize

import android.provider.OpenableColumns; //導入依賴的package包/類
public static InfoItem retrieveFileSize(Context context, Uri uri) {
    //retrieve fileSize form MediaStore
    Cursor cursor = context.getContentResolver().query(
            uri, null, null,
            null, null);
    long size = 0;
    if (cursor != null && !cursor.isAfterLast()) {
        int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            size = cursor.getLong(sizeIndex);
            cursor.close();
        }
    }
    return new InfoItem(context.getString(R.string.info_size), Parser.parseFileSize(context, size));
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:17,代碼來源:InfoUtil.java

示例13: getNameFromUri

import android.provider.OpenableColumns; //導入依賴的package包/類
static String getNameFromUri(@NonNull Context context, @NonNull Uri uri) {
    String result = null;
    if (uri.getScheme().equals("content")) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        if(cursor != null) {
            //noinspection TryFinallyCanBeTryWithResources
            try {
                if (cursor.moveToFirst()) {
                    result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
                }
            } finally {
                cursor.close();
            }
        }
    }
    if (result == null) {
        result = uri.getPath();
        int cut = result.lastIndexOf('/');
        if (cut != -1) {
            result = result.substring(cut + 1);
        }
    }
    return result;
}
 
開發者ID:customerly,項目名稱:Customerly-Android-SDK,代碼行數:25,代碼來源:IU_Utils.java

示例14: getFileSize

import android.provider.OpenableColumns; //導入依賴的package包/類
private long getFileSize(Uri uri) {
    long size = -1;

    Cursor cursor = getContext().getContentResolver().query(uri, null, null, null, null);
    if (cursor != null) {
        try {
            int rowsCount = cursor.getCount();
            if (rowsCount > 0 && cursor.moveToFirst()) {
                int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
                int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);

                return cursor.getLong(sizeIndex);
            }
        } finally {
            cursor.close();
        }
    }

    return size;
}
 
開發者ID:croconaut,項目名稱:wifon-mini,代碼行數:21,代碼來源:NearbyListFragment.java

示例15: getFilename

import android.provider.OpenableColumns; //導入依賴的package包/類
public static String getFilename(Uri uri, Context context) { 
    String fileName = null;
    String scheme = uri.getScheme();
    if (scheme.equals("file")) {
        fileName = uri.getLastPathSegment();
    }
    else if (scheme.equals("content")) {
        Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
        try {
          if (cursor != null && cursor.moveToFirst()) {
              fileName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
          }
        } finally {
          cursor.close();
        }           
    }
    return fileName;
}
 
開發者ID:anokhina,項目名稱:AudioBookPlayer,代碼行數:19,代碼來源:Util.java


注:本文中的android.provider.OpenableColumns類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。