Use of resources in Android

Source: Internet
Author: User

1. Open an APK package:

meta-inf\
Androidmanifest.xml
Calsses.dex
Lib\
Resources.arsc
Res\
Assets\

The other three are the resources in the Android project. Includes pictures, audio, video, XML files, and more.
RESOURCES.ARSC includes the index of the resource under RES, the XML file under the Values folder under Res (that is, the XML file whose root node is the resources).
Res\ Res In addition to the values of other files, in addition to raw under the original file, the other will be compiled into binary files. The folder structure under this folder is fixed.

Assets\ the original resource file to use for Android projects is typically placed under this folder. The difference from the first two is that the resource under assets does not generate a global identity in the R file.

2, resources is these, use of resources we use two things and Assetmanager.

Assetmanager:
Official notes
This class presents a Lower-level API, allows you to open and read raw files
That has been bundled with the application as a simple stream of bytes.


1) Assetmanager can be obtained through the Getassets () method of the context.
2) Assetmanager is a bottom-level API with some native functions.
3) The public function of Assetmanager is provided to access files under the Assets folder:
List (path) returns an array of file name strings under Path
Open (filename) returns a InputStream
The parameters of the above two functions are relative to the assets folder.
4) Assetmanager also has a default modification method that implements fetching values from the resource file. Resources are using these methods of Assetmanager to implement resource access operations.

Resources:

Class for accessing an application ' s resources.
This sits on top of the asset manager of the application (accessible throughgetAssets())
and provides a high-level API for getting typed data from the assets.

1) resources can be obtained using the Getresources () method of the context.
2) Resources primarily provides a way to get the values defined in a resource using the resource ID:
Http://www.android-doc.com/reference/android/content/res/Resources.html
GetColor (ID)
Getdimension (ID)
GetLayout (ID)
GETXML (ID) This method can be used to parse our own XML file defined under Res/xml
......
  
  

Use of resources in Android

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.