A011-raw resources, rawstrokes Resources
The previous article introduced assets resources. This section describes the raw resources in the res directory and the path is res/raw. In addition to processing assets resources, the resource files involved in our program are all under the res directory, such as the drawable and menu resources described earlier. Other resource types will be introduced later.
How do we obtain raw resources? What are the similarities and differences between the resources in the assets Directory? This is what Android Developers need to pay attention.
Commonalities
Both of them will not be compiled into binary files, that is, they will not be packaged into the apk file.
Differences
-Assets are not mapped to the R file, while raw resources are mapped to the R file.
-Raw resources can be referenced through R. raw. filename.
-Assets can have a directory structure, while raw cannot.
Eg: Read txt files under res/raw
Public void readRaw () {InputStream inputStream = getResources (). openRawResource (R. raw. demo); textView. setText (read (inputStream);} private String read (InputStream inputStream) {try {ByteArrayOutputStream osStream = new ByteArrayOutputStream (); int length; while (length = inputStream. read ())! =-1) {osStream. write (length);} return osStream. toString ();} catch (IOException e) {return "file read/write failed ";}}
Reference: http://www.cnblogs.com/leizhenzi/archive/2011/10/18/2216428.html
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.