res assets

* Similarities res / raw and assets of:

1. Both files directory after package will be stored in intact apk package, will not be compiled into a binary.

* Res / raw and assets of the differences:

1.res / raw files are mapped to R.java file when accessed directly using the resource ID that is R.id.filename; file assets folder will not be mapped to the R.java, visit AssetManager class when needed.

2.res / raw not have a directory structure, and assets you can have a directory structure, which is under the directory assets can then create a folder

* Read the file resources:

1. Read res / file resource in raw, takes an input stream by the write operation is performed in the following manner

InputStream is = getResources().openRawResource(R.id.filename);  

2. (1) to read the file in the resource assets, takes an input stream by the write operation is performed in the following manner

AssetManager am = null;  

am = getAssets();  

InputStream is = am.open("filename");  

  (2) If Videoview to play:

  VideoView.setVideoUri(Uri.parse("android.resource://" + getpackageName() + "/" + R.raw.movie));

Reproduced in: https: //www.jianshu.com/p/cd9d401372eb

Guess you like

Origin blog.csdn.net/weixin_33811539/article/details/91226833