We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

File Structure

App Resources

An app contains the manifest.json file that describes the project configurations, the app.ux file that records the common resources of the project, and multiple UX files, each of which describes a page or custom elements. A typical example is as follows:

App directory

|—— manifest.json

|—— app.ux

|—— Page1

| |—— page1.ux

|—— Page2

| |—— page2.ux

|—— Common

|—— ComponentA.ux

|—— ComponentB.ux

|—— xxx.png

Common resource files and element files are stored in the Common directory. Resource files and element files (for example, image, CSS, and JS files) dedicated to a page are stored in the directory of that page.

NOTICE

All file names in a project can contain only letters, digits, periods (.), underscores (_), hyphens (-), and parentheses (()) but cannot contain double dot (..) or dot-slash (./). Each file name can contain at most 300 characters.

File Storage

On app platforms, files are stored by partition. Currently, the following partitions are supported:

  • Cache: generally used to store cache files. For example, files downloaded through the fetch API are stored in this partition. Files in this partition may be deleted by the system due to insufficient storage space.
  • Files: generally used to store small permanent files. Files in this partition are managed by apps themselves.
  • Mass: generally used to store large files. This partition is not always available. Huawei Quick App Center allocates a storage directory in the SD card as the actual storage path of the Mass partition. Other apps on the phone have permission to read this storage path.
  • Temp: used to store temporary files mapped from external systems. For security purposes, temporary files are read-only and can be obtained only by calling specified APIs, for example, the media.pickVideo API. In addition, temporary files in this partition cannot be accessed after app restart, so you need to call specified APIs to obtain the temporary files again. App resources can be placed in this partition for processing.
NOTICE

Data processed by the quick app APIs may be read by other apps when being used on a PC. Therefore, you are not advised to store sensitive data.

URI

URIs are used to identify app resources and files, and elements and APIs access app resources and files based on URIs.

Expand

Resource Type

URI

Read-Only

Example

Description

App resources

/path

Yes

/Common/header.png

-

Cache

internal://cache/path/

No

internal://cache/fetch-123456.png

Content directory of Huawei Quick App Engine, which can be accessed by users.

Files

internal://files/path

No

internal://files/image/demo.png

Content directory of Huawei Quick App Engine, which can be accessed by users.

Mass

internal://mass/path

No

internal://mass/video/demo.mp4

External directory, which can be accessed by users.

You can access the /Android/data/com.huawei.fastapp.dev/files/fastappEngine/ directory through the file manager and then access this external directory.

Temp

internal://tmp/path

Yes

internal://tmp/xxxxx/demo.png (file name)

The URI is automatically generated by the system.

The regular expression [^\\s\"':|*?<>\\\\]+ can be used to verify the URI enclosed in quotation marks. A URI cannot contain a double dot (..). A URI supports the directory structure where directories are separated by slashes (/). An internal URI indicates a file dedicated to an app. The app ID does not need to be specified in an internal URI. Internal URIs dedicated to different apps point to different files even when they are the same.

Resource and File Access Rules

App resource paths are classified into absolute paths and relative paths. A path starting with a slash (/), for example, /Common/a.png, is an absolute path. A path not starting with a slash (/), for example, a.png or ../Common/a.png is a relative path.

App resource files are classified into code files and resource files. Code files are files that contain code, such as JS, CSS, and UX files. Other files are resource files such as image and video files.

  1. To import a code file, use its relative path, for example, ../Common/component.ux.
  2. To reference a resource file (for example, an image file or a video file), use its relative path, for example, ./abc.png.
  3. To reference a resource file in a code file imported to another code file, use a relative path of the resource file if the two code files are in the same directory, and use an absolute path if they are in different directories. That is because the path will be copied to the target file when the imported file is compiled, and the directory will change after the compilation is complete.

For example, the a.css file is imported to the b.ux file. If they are in the same directory, use a relative path of a resource file, for example, abc.png, to reference this resource file in the a.css file; if they are in different directories, use an absolute path, for example, /Common/abc.png.

For example, the a.ux file is imported to the b.ux file. If they are in the same directory, use a relative path, for example, a.png, to reference this resource file in the a.ux file; if they are in different directories, use an absolute path, for example, /Common/abc.png.

Same as frontend development, you can use the url(Path) method to access a resource file in a CSS file. For example, use url(/Common/abc.png) to access the abc.png file.

Search
Enter a keyword.