# FileBackup **Repository Path**: dong-haifan/FileBackup ## Basic Information - **Project Name**: FileBackup - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 5 - **Created**: 2025-03-05 - **Last Updated**: 2026-01-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Local Backup and Restoration of User Files ### Overview This sample implements local backup and restoration of user files based on the fs and picker modules. It demonstrates how to access user files and application files and how to perform basic file operations such as copying, deleting, saving, compressing, decompressing, and previewing gallery files and document files, helping you master file access and operation skills. ### Preview | Home page | |------------------------------------| | ![image](screenshots/index_en.png) | ### How to Use: This sample includes the following steps: 1. Click + to import or create a file. 2. Click an item in the file list to preview the file. 3. Click Save to save a file to Gallery/Documents. 4. Click Delete to delete a file. ### Project Directory ``` ├──entry/src/main/ets/ │ ├──common │ │ └──utils │ │ ├──DocumentFile.ets // Document file operation │ │ ├──FileOperate.ets // File read and write operation │ │ ├──FilePreview.ets // File preview │ │ └──PhotoFile.ets // Image file operation │ ├──entryability │ │ └──EntryAbility.ets // Entry ability │ ├──entrybackupability │ │ └──EntryBackupAbility.ets // Backup and restoration │ ├──model │ │ └──DataBase.ets // Database operation │ ├──pages │ │ └──Index.ets // Home page │ ├──view │ │ ├──AddFileButton.ets // File import button │ │ ├──ImportFileDialog.ets // File import dialog box │ │ ├──ListItemView.ets // File list item view │ │ └──NewFileDialog.ets // File creation dialog box │ └──viewmodel │ └──FileViewModel.ets // File list item └──entry/src/main/resources // Application resource directory ``` ### How to Implement 1. Use the photoViewPicker.select() method to obtain images from Gallery. 2. Use the documentViewPicker.select() method to obtain files from Documents. 3. Use the photoAsset.getThumbnail() method to obtain the thumbnail of an image. 4. Use the zlib.compressFile() method to compress a file. 5. Use the zlib.decompressFile() method to decompress a file. 6. Use the filePreview.openPreview() method to preview a file. 7. Use the phAccessHelper.showAssetsCreationDialog() method to save an image to Gallery. 8. Use the documentViewPicker.save() method to save a file to Documents. ### Permissions N/A ### Dependency N/A ### Constraints 1. The sample is only supported on Huawei phones with standard systems. 2. The HarmonyOS version must be HarmonyOS 5.0.5 Release or later. 3. The DevEco Studio version must be DevEco Studio 6.0.2 Release or later. 4. The HarmonyOS SDK version must be HarmonyOS 6.0.2 Release SDK or later.