原始资源Uri导致FileNotFoundException(没有这样的文件或目录)



我需要访问原始资源中的一个文件,我正在尝试获取Uri,稍后将在FileInputStream中使用,但我收到:

10-17 22:51:47.338:W/System.err(5619):java.io.FileNotFoundException:/raw/help_content(没有这样的文件或目录)

这就是我创建Uri:的方式

    Uri rawHelpZip = Uri.parse("android.resource://"
            + context.getPackageName() + "/raw/help_content");

我也试过这个:

    Uri rawHelpZip = Uri.parse("android.resource://"
            + context.getPackageName() + "/"+R.raw.help_content);

注意:help_content是一个zip文件,这与我的问题有关吗?

这样做,使用方法中构建的上下文更干净

InputStream is = context.getResources().openRawResource(R.raw.help_content);
// Do something with the InputStrem                        

最新更新