当前位置: 首页>>代码示例>>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;未经允许,请勿转载。