Here is what I get from my experience by tidying up the Internet.
The same point of raw and assets
They will be copied to the APK in their entirety, without being compiled into binary form like other resource files.
Different points of raw and assets
They are in different ways in the code:
Assets:
InputStream assets = getAssets().open("xxxx");
Raw:
InputStream raw = getResources().openRawResource(R.raw.xxxx)
Assets can create a directory structure, but also can dynamically list all the resources in the assets ( getAssets().list(String path);
), raw file directory does not
The resource under the Raw folder generates a resource under the Id,assets file does not
Usage scenarios for raw and assets
Because Raw is a subdirectory of the resources (RES), Android automatically generates an ID for all resource files in this directory, which is stored in the R class as a reference to a file. This means that this resource file can be easily accessed by Android classes and methods, even in the form of an Android XML file you can @raw/
refer to it. In Android, using an ID is the quickest way to access a file. MP3 and Ogg files in this directory are more appropriate.
The assets directory is more like an appendix type directory, Android does not generate an ID for the files in this directory and is saved in the R class, so it is less compatible with some classes and methods in Android. At the same time, because you need a string path to get the file descriptor in this directory, the access speed will be slower. But putting some files in this directory can make things easier, such as copying a database file into system memory. Note that you cannot refer to files in the assets directory in the Android XML file, only through Assetmanager to access the files. Database files and game data are better placed in this directory.
Differences between raw and assets folders in the #Android