简体   繁体   中英

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. 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:

Uri uri = Uri.parse("android.resource://" + getPackageName() + "/raw/tree");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM