The difference between android:assests and raw

Source: Internet
Author: User

Transferred from:http://www.cnblogs.com/lianghui66/p/3248636.html

------------------------------------------------------------------------------------------------------------

The same points as *res/raw and assets:

1. The files in both directories will be stored intact in the APK package after packaging, and will not be compiled into binary.


Different points of *res/raw and assets:
The files in the 1.res/raw are mapped to the R.java file, and the files under the R.id.filename;assets folder are not mapped to R.java when accessed, and Assetmanager classes are required for access.
2.res/raw can not have a directory structure, and assets can have a directory structure, that is, assets directory can be re-established folder

* Read File resources:

1. Read the file resource under the Res/raw, and get the input stream for write operation in the following way

    • InputStream is = Getresources (). Openrawresource (R.id.filename);

2. (1) Read the file resource under assets, and obtain the input stream for write operation by the following way

    • Assetmanager am = null;
    • am = Getassets ();
    • InputStream is = am.open ("filename");

(2) If you use Videoview to play:

Videoview.setvideouri (Uri.parse ("android.resource://" + getpackagename () + "/" + R.raw.movie));

The difference between android:assests and raw

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.