The difference between raw and assets

Same point:

After packaging, it will be directly stored in the apk and will not be compiled into a binary file. So it can be used to save database files, audio and video files, etc.

difference:

1. The access methods are different. The files in the raw folder are mapped to R.java, which can be accessed using R.raw.*, while the files in the assets folder must be accessed through the open() method of the AssetManager class.

2. There cannot be a directory structure under raw, but a new folder can be created under the assets folder.

How to access:

1. Access the files in the raw folder

InputStream in = getResources().openRawResource(R.raw.*);

2. Access the files under assets

InputStream in = getAssets().open("filename");

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325942725&siteId=291194637