[英]Finding the path of a file in the raw folder?
I try to have the path in string of some fbx and shp file in my project's raw folder in android studio.我尝试在我的项目的原始文件夹中使用一些 fbx 和 shp 文件的字符串路径。 I have try a lots of think but it never work.我已经尝试了很多思考,但它从来没有奏效。
String file= getExternalFilesDir(null).getAbsolutePath() + "/tree.fbx";
//or
Uri uri = Uri.parse(
"android.resource://"
+ getPackageName()
+ "/"
+ R.raw.tree
);
String uritree=uri.getPath();
//or
String modelURI = new File(this.getDataDir().getAbsolutePath()+"/raw", "tree.fbx").getAbsolutePath();
I don't want to open the file, I realy need to have the path to be using in another library.我不想打开文件,我真的需要有在另一个库中使用的路径。
I think you're close.我认为你很接近。 Try a slight variation of your 2nd option, instead of using R.raw.tree in your path, use raw/tree:尝试对第二个选项稍作改动,而不是在路径中使用 R.raw.tree,而是使用 raw/tree:
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/tree");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.