In the establishment of the project will generally default to establish the assets file, of course, we can also create a raw folder under the Res file, where the surface can hold some multimedia files or text information, can be used in our program.
Assets the following files will not be compiled, and the path can be used to access the contents. The files in raw are automatically compiled and we can find the corresponding IDs in the R.java file.
One of the more important is to get the resource methods in assets and raw (for file test.txt)
Assets:inputstream InputStream = = Getassets (). open (Test.txt);
Raw:inputstream InputStream = Getresources (). Openrawresource (R.raw.test);
Add:
We all know that the establishment of an Android project will produce assets and res two folders, in theory they are the folder to store resources, then what is the difference between them?
1.assets: The corresponding tag will not be generated under the R.java file, and the resources stored here will be bundled into the program installation package when the package is run.
2.res: tokens are generated under the R.java file, where the resources are used to determine which ones are in use when the package operation is run, and the file resources that are not used are not packaged in the installation package.
You can actually define the directory under the Res folder:
Res/anim: This is an animated resource.
res/xml: You can use GetResource () in activity. GetXML () Read the resource file here
Res/raw: files in this directory can be copied directly to the device, compile the software, the data here does not need to compile, directly into the program installation package, using the method is GetResource (). Openrawresources (ID), where the parameter ID is in the form of r.raw.xxx.
Add a point:res can only establish a system-approved directory, and can only establish a level, the following can not have subdirectories, and assets below may be placed any number of any multilevel. "From 2 floor reviews"
Use of assets and AW files for Android interview