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

Introduction to Application Data Migration

Usage scenario

When a device is upgraded from HarmonyOS 3.1 Release API 9 or earlier (HarmonyOS for short) to HarmonyOS NEXT Developer Preview1 or later (HarmonyOS NEXT for short), the APK applications running on HarmonyOS must be switched to the HarmonyOS applications in HarmonyOS NEXT after a system upgrade. Some data of the APK applications can be accessed by the HarmonyOS applications only after it is converted and migrated to the specified storage path. HarmonyOS NEXT provides a data migration framework and a backup and restore framework to enable developers to migrate and convert application data. After the APK is switched to a HarmonyOS app, the data that is compatible with the HarmonyOS app in the original APK can be inherited.

As shown in the following figure, the data required by the application includes the data in the cloud server, data in the local application sandbox, and data in the local public media library. To ensure that the application data can be inherited, the cloud data definition must be compatible with APK applications and HarmonyOS applications so that data of the same account can be identified after the system upgrade.

Data Migration Mechanism

Application Sandbox Data Migration

After a device is upgraded from HarmonyOS to HarmonyOS NEXT, the APK application sandbox data is migrated to the intermediate directory. For application sandbox data, HarmonyOS NEXT provides a data migration framework to schedule application data migration tasks in a unified manner.

An application data migration task involves application installation, data migration, and data restoration.

  1. Application installation:

    1. The data migration framework sends HarmonyOS application download and installation requests to HUAWEI AppGallery.
    2. The HarmonyOS application is downloaded from HUAWEI AppGallery and installed.
  2. Data migration:

    After the HarmonyOS application is installed, the data migration framework migrates the application sandbox data from the intermediate directory to the backup and restore directory.

  3. Data restoration:

    1. After the application data is migrated to the backup and restore directory, the data migration framework sends an application data restoration request to the backup and restore framework.
    2. The backup and restore framework starts the BackupExtensionAbility independent process of the application to restore application data.
    3. The application calls BackupExtensionAbility to load APK application data from the backup and restore directory, process the data, and save the processed data to the HarmonyOS application sandbox for restoration.
    4. After the application data is restored, the backup and restore framework clears the backup and restore directory.

After that, the HarmonyOS application accesses the HarmonyOS application sandbox to obtain application data.

Data Migration Mechanism in the Public Media Library

Data in the public media library will be migrated and inherited after devices are upgraded from HarmonyOS to HarmonyOS NEXT. Applications can access data in the public media library using the APIs provided by HarmonyOS NEXT. For details about how to use the media library, see Media Library Kit Overview.

Search
Enter a keyword.