目录

Accessing Device Files

DevEco Studio provides Device File Browser that simplifies file management on connected devices. You can create, delete, upload, and download files on the target device without using any CLI. Currently, Device File Browser offers two views: file view and app sandbox view.

Scenarios

Constraints

Procedure

  1. On the menu bar, choose View > Tool Windows > Device File Browser to start Device File Browser.

  2. Select a device from the drop-down list box.
  3. After you select a device, the file/folder list of the device is displayed. You can perform the following operations:

    1. Create or delete a file or folder.
    2. Transfer files between the local PC and the device. To download a file or folder to the local PC, right-click the file or folder and choose Save As. To upload a file to the device, right-click the file on the local PC and choose Upload.

      To view a database file, you can download the database file (for example, data > app > el2 > 100 > database > Project name > entry > rdb > File name) to the PC and use other tools to view the file.

      Since DevEco Studio 6.0.0 Beta2, you can hold down Ctrl or Shift and click the left mouse button (hold down Command or Shift and click the left mouse button on macOS) to select multiple files or directories for downloading to your local computer. Since DevEco Studio 6.0.2 Beta1, the same multi-select capability is supported for deleting multiple files or directories.

    3. Enter a keyword in the Device File Browser text box to search for a file.
    4. Double-click a file to open it on DevEco Studio. The file opened is downloaded to a temporary directory (%USER%\AppData\Local\Huawei\DevEcoStudio{Version number}\device-file-browser\{Device name}\{File path on the device}) by default. After the file is closed, the temporary file will be automatically deleted.
    5. If a file is uploaded to the device using a command, you need to right-click the folder and choose Synchronize from the shortcut menu. Then, the file can be displayed in the Device File Browser window.

Accessible Directories

Device File Browser provides access to the following directories: app sandbox directory, temporary directory, log directory, device public directory, and media library directory.

[h2]App Sandbox Directory

The app sandbox directory is where data and resource files related to the app are stored. You can access this directory in two ways:

[h2]Temporary Directory

The temporary directory, at /data/local/tmp/, is used to store temporary files generated during debugging and testing. You can create, delete, upload, and download files in this directory.

[h2]Log Directory

When your app is running, logs are generated in real time using HiLog and stored in the HiLog output buffer, which is typically 256 KB. When the buffer reaches its capacity, historical logs are saved as compressed packages in the /data/log/hilog/ directory.

To view historical logs, download the compressed packages and the hilog_dict.XXX.zip file (data dictionary file) in the directory, and then use the hilogtool to parse the log files.

[h2]Public Directories

The public directories, such as Desktop, Documents, and Downloads, are at /storage/media/100/local/files/Docs. You can delete, upload, and download files in these directories.

[h2]Media Library Directory

Since API version 22, the media library directory /mnt/data/100/media_fuse/Photo has been added. The original directory /storage/media/100/local/files/Photo is now a symbolic link that redirects to /mnt/data/100/media_fuse/Photo. This new directory enables upload, download, and deletion of image and video files.

Wearables do not support the media library directory.

Special Directories

There are two special directories on the device: faultlog and gallery directories. These directories are not displayed in Device File Browser, but can be accessed using hdc commands.

[h2]faultlog Directory

When an app crashes, a crash log is generated and saved in /data/log/faultlog/faultlogger. While you cannot view this directory directly in Device File Browser, you can access and export its contents using hdc commands.
  1. To query the crash log list:
    • For devices running versions earlier than 5.1.0.54:
      hdc shell hidumper -s 1201 -a "-p Faultlogger"

    • For devices running 5.1.0.54 or later (the timestamp includes milliseconds):
      hdc shell hidumper -s 1201 -a "-p Faultlogger %s -LogSuffixWithMs"

  2. To view a specified crash log file:
    hdc shell hidumper -s 1201 -a "-p Faultlogger -f {filename}"

  3. To download the log file to the specified path on your local PC:
    hdc file recv /data/log/faultlog/faultlogger/{filename} {path}

[h2]Gallery Directory

The gallery directory stores image and video files generated by system apps, such as the screen recorder and camera. To download these files to your local PC, perform the following:

  1. View the file name and extension of the desired media file, for example, a.mp4.

  2. Query the file path and record it as {FilePath}.
    hdc shell mediatool query a.mp4 -u
    • If the query result contains the uri field, the file path (on the third line of the result) cannot be directly used for download.

      In this case, use the value of uri to save the file to a path on which you have the download permission, for example, /data/local/tmp:

      hdc shell mediatool recv file://media/Photo/2/VID_1744944984_000/a.mp4 /data/local/tmp

      The second line in the output is the downloadable file path.

    • If the query result does not contain the uri field, the downloadable file path is listed on the second line of the output.

  3. Use the downloadable file path to download the file to your local PC.
    hdc file recv {FilePath} .\

Accessing the App Sandbox in CLI Mode

You can access the sandbox directory of debug apps through the CLI.

FAQs

What should I do if opening a folder in the app sandbox view displays the "[Fail][E003001] Invalid bundle name" message?

Follow the steps below to troubleshoot:

  1. Check whether the app is a debug app. Only debug apps support sandbox file access.
  2. Check whether the app has been launched at least once. If the app has not been run yet or the device was restarted after installation, the app sandbox may not be mounted. To fix the issue, run the app and then right-click the target folder in Device File Browser and choose Synchronize.