如何通过默认应用程序android打开目录

时间:2012-08-20 04:19:31

标签: android android-intent

请帮我解决这个问题。 我知道如何在默认应用程序中打开文件,如下所示:

    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    File file = ExternalStorageHelper.getFileFromName(fileName);
    MimeTypeMap mime = MimeTypeMap.getSingleton();
    String ext =fileName.substring(fileName.lastIndexOf(".")+1);
    String type = mime.getMimeTypeFromExtension(ext);
    if(type != null){
        if(mime.hasMimeType(type)){
            intent.setDataAndType(Uri.fromFile(file),type);
            containActivity.startActivityForResult(intent,1);
        }else{
            Toast t = Toast.makeText(containActivity, R.string.download_open_file_error_message, Toast.LENGTH_SHORT);
            t.show();
        }
    }else{
        Toast t = Toast.makeText(containActivity, R.string.download_open_file_error_message, Toast.LENGTH_SHORT);
        t.show();
    }

但我无法找到默认应用程序如何打开文件夹。 从这段代码中我如何确定MimeTypeMap fileName是一个目录。

我现在真的需要它,请帮助我:)。

1 个答案:

答案 0 :(得分:1)

  

不幸的是,没有内置的方法可以做到这一点。你可以尝试使用   OI FileManager - 非常好,但用户需要   安装应用程序以使用它。

     

还有一个如何在这里制作自己的好例子。

How do I open the file browser? ( Android SDK)