Android Raw and assets resources

Source: Internet
Author: User

*res/raw and assets the same point:

1. Files in both folders 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. Use the resource ID, or r.id.filename, directly when visiting. Files in the assets directory are not mapped to R.java, and the Assetmanager class is required when visiting.


2.res/raw can not have a folder structure, while assets can have a folder structure. That is, you can create folders under the Assets folder

* Read File resources:

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

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

2. (1) Read the file resources under assets. Get the input stream for write operations in the following way

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

(2) Suppose to play with Videoview:

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

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Android Raw and assets resources

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.