In-depth analysis of official Android commands: bmgr and androidbmgr

Source: Internet
Author: User

In-depth analysis of official Android commands: bmgr and androidbmgr

Author: Song Zhihui

Bmgr is a shell tool that can interact with Backup Manager. To use this tool, the minimum API size for Android devices is 8. it provides backup and recovery commands, so you do not need to clear data frequently. These commands are accessed through the adb shell.

Forced backup

Normally, when your application changes its data, it must notify the Backup Manager through the dataChanged () method. Backup Manager will call the onBackup () method of your Backup proxy at a certain time in the future. However, in addition to calling the dataChanged () method, you can run the bmgr backup command to initiate a backup request.

Adb shell bmgr backup <package name>

<Package name> is the package name of the application you plan to back up. When you execute this BACKUP command, the backup proxy of your application will be called to execute a series of backup operations through the onBackup () method, but you cannot determine when to execute it. However, you can use the bmgr run Command to force the backup operation immediately:

adb shell bmgr run

This can cause the backup operation to be executed immediately. Trigger the backup proxy of all applications and call the dataChanged () method after the last backup operation is completed. Any application can schedule backups manually through bmgr backup.

Force recovery

Unlike the backup operation, the recovery operation is executed immediately. Backup Manager now provides two recovery operations. The first is to back up the data of the entire device. This usually occurs when the device is used for the first time and only the system can perform the backup. The second recovery operation restores the Active Data settings of a single application, which means that the application will disable the current data and replace it with the last backup data. You can call the requeRestore () method. Backup Manager will call the onRestore () method of your Backup proxy.
When you test your application, you can use the bmgr restore command to restore the application:

adb shell bmgr restore <package>

Indicates the registration of the application to be restored. The Backup Manager will immediately perform the restoration operation, provided that the application is not currently running.

Other commands

Clear Data

Data of a single application can be erased from an active data group as needed. This is useful when you develop a backup proxy to prevent the bugs from writing bad data or saving status information. You can run the bmgr wipe command to erase application data.

adb shell bmgr wipe <package>

The package name of the application that you want to erase data. The next backup operation application is considered as having never been backed up before.

Enable and disable backup

You can use the bmgr enbled command to enable Backup Manager.

adb shell bmgr enabled

This command is very useful for your application to never call a backup proxy for backup. Used to verify whether the operating system deems it necessary to perform similar operations.

You can also disable Backup Manager using the following command:

adb shell bmgr enable <boolean>

Warning after the backup is disabled, the backed up data is cleared.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.