raw asset

Current Location: Home  >> Development Information Welcome to this article, the potential of this article is looking forward to your discovery

How to get the path of res/raw and assets folder in android development

 

    How to obtain the paths of res/raw and assets folders in android development is mainly divided into two cases:

    1. If you just copy the action, then you only need to get the res/raw and assets file input stream, the method is as follows:

    Get the res/raw file input stream: InputStream is=getResources().openRawResource(R.raw.XXX);
    Get the assets file input stream: InputStream is=getResources().getAssets().open("file name");

    2. If you want to write actions for res/raw and assets files, you need to get the corresponding uri, the method is as follows:

    Get the uri of res/raw: Uri uri=Uri.paese("android:resource://package name/"+R.raw.xxx);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940384&siteId=291194637