Tool Name: airdroid_business_clear_app_data_and_cache
Risk Level: 🔴 High Risk
Execution Mode: ⏳ Asynchronous
Category: Security Operations
Quick Start (Copy & Use)
One-liner: Remotely clear data and cache from a specified app on a device
What you need: DeviceId (device ID), PkgId (app package name), Confirm (must be set to true), Reason (reason for the operation)
Success criteria: StatusCode = 200 and ErrorMessage is an empty string; returns Pid for tracking
What to do next: Use Get an Activity Log with the Pid to poll execution status
Minimal request example:
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"PkgId": "com.facebook.katana",
"Confirm": true,
"Reason": "User requested data reset for troubleshooting"
}
Minimal response example:
{
"Pid": "1770854462319857000",
"StatusCode": 200,
"ErrorMessage": ""
}
Recipes (Common Recipes)
Recipe 1: Clear app data for troubleshooting
Scenario: An app on a field device is malfunctioning — clear its data and cache to reset it
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"PkgId": "com.example.fieldapp",
"Confirm": true,
"Reason": "App crashing repeatedly, clearing data to reset"
}
Recipe 2: Clear browser data for security
Scenario: A shared kiosk device needs its browser data cleared for security compliance
{
"DeviceId": "abc123def456",
"PkgId": "com.android.chrome",
"Confirm": true,
"Reason": "Periodic browser data cleanup for security compliance"
}
Recipe 3: Track clear data status with Pid
Scenario: After clearing app data, confirm whether the operation completed successfully
- Call Clear App Data and Cache to get the Pid
- Use the Get an Activity Log tool to query status:
{
"Pid": "1770854462319857000"
}
Polling logic:
- Progress = "Executing" → continue polling (interval 5-10 seconds)
- Progress = "Success" → data cleared successfully
- Progress = "Failure" → check the FailReason field
1. Overview
1.1 Description
Remotely clear data and cache from a specified app on a device managed by AirDroid Business. This operation permanently deletes the app's local data including user settings, cached files, login sessions, and locally stored content.
1.2 When to Use
- App troubleshooting: Clear corrupted app data to resolve crashes or malfunctions
- Security compliance: Periodically clear sensitive data from shared or kiosk devices
- User reset: Reset an app to its initial state (e.g., after employee departure on a shared device)
- Storage management: Free up device storage by clearing large app caches
1.3 Execution Mode & Response
This operation is asynchronous — after the command is sent, the device may take seconds to minutes to respond.
- Return value: Pid (activity log ID)
- Tracking method: Use the Get an Activity Log tool with the Pid to query execution status
- Prerequisite: The device must be online to receive the command
- Critical: All app local data (settings, cache, login sessions) will be permanently deleted and cannot be recovered
1.4 Prerequisites
| Condition | Description | How to Check |
|---|---|---|
| Device online | The device must be online to receive the command | Use Get All Devices with {"online":"Online"} filter |
| Valid package name | The app must be installed on the device | Use Get All Device Apps to confirm the app exists |
| User confirmation | Must obtain explicit user consent before execution | Confirm parameter must be set to true |
| Reason provided | A reason must be supplied for auditing | Reason parameter must not be empty |
1.5 Prerequisite Tools
| Tool | Purpose | Necessity |
|---|---|---|
| Get All Devices | Obtain DeviceId and confirm device is online | 🔴 Required |
| Get a Device by Name | Query DeviceId by exact device name | If only the device name is known |
| Get All Device Apps | Obtain the app package name (PkgId) | 🔴 Required (if package name is unknown) |
| Get a Device App by Name | Look up an app by name to get its package name | If only the app name is known |
1.6 Comparison with Similar Tools
| Tool | Use Case | Difference |
|---|---|---|
| Clear App Data and Cache | Reset a specific app's data | Clears only the specified app's data and cache |
| Factory Reset | Wipe entire device | Erases all data on the device, not just one app |
| Unenroll a Device | Remove device from management | Device leaves MDM, does not clear app data |
2. Inputs
2.1 Parameter List
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| DeviceId | string | ✅ Yes | - | Device unique identifier |
| PkgId | string | ✅ Yes | - | Android app package name (e.g., com.example.app) |
| Confirm | bool | ✅ Yes | false | Safety confirmation; must be set to true to execute |
| Reason | string | ✅ Yes | - | Reason for the operation, used for audit logging |
2.2 Parameter Details
`DeviceId`
Device unique identifier, specifying the target device.
- Type: string
- Format: Non-empty string
- Source:
- Obtained via the Get All Devices tool; use the device_id field from the response
- Obtained via the Get a Device by Name tool for exact name lookup
- How to fill in a GI node:
- Constant: Enter the device ID string directly, e.g. fa6edcff65ab444e8b5e0eb08df4175d
- Upstream reference: Map from the Get All Devices node's Devices[0].device_id field
- Example:
"fa6edcff65ab444e8b5e0eb08df4175d"
`PkgId`
Android app package name identifying the target app whose data and cache should be cleared.
- Type: string
- Format: Android package name format (e.g., com.facebook.katana, com.android.chrome)
- Source:
- Obtained via the Get All Device Apps tool; use the package_name field from the response
- Obtained via the Get a Device App by Name tool for app name lookup
- How to fill in a GI node:
- Constant: Enter the package name directly, e.g. com.facebook.katana
- Upstream reference: Map from the Get All Device Apps node output
- Example:
"com.facebook.katana"
`Confirm`
Safety confirmation parameter. This is a guardrail parameter for high-risk operations, preventing accidental execution of destructive actions.
- Type: bool
- Default: false (will not execute)
- Must be set to true to execute: If false, the operation will be rejected with an error
- How to fill in a GI node:
- Constant: Only set to true after receiving explicit user consent
- Example:
true
⚠️ Important: The agent must ask the user for confirmation before calling this tool. Only set this parameter to true after receiving explicit user approval.
`Reason`
Reason for clearing app data and cache.
- Type: string
- Format: Non-empty string; a clear description is recommended
- Why required: Logged for auditing purposes to support tracking and compliance
- How to fill in a GI node:
- Constant: e.g. "User requested data reset for troubleshooting"
- Upstream reference: Obtain from user input or a ticketing system
- Example:
"User requested data reset for troubleshooting"
⚠️ Important: The Reason parameter must be provided by the user. The agent should not fabricate reasons.
2.3 Parameter Combination Logic
- All four parameters are required
- Confirm must be true and Reason must be non-empty for the operation to execute
- If Confirm = false, returns StatusCode = 200 with an ErrorMessage indicating confirmation is required
3. Outputs
3.1 Response Examples
Success response:
{
"Pid": "1770854462319857000",
"StatusCode": 200,
"ErrorMessage": ""
}
Confirmation not passed:
{
"Pid": "",
"StatusCode": 200,
"ErrorMessage": "Confirm must be set to true to execute this destructive operation."
}
Missing reason response:
{
"Pid": "",
"StatusCode": 200,
"ErrorMessage": "Reason is required for audit trail."
}
Parameter error response:
{
"Pid": "",
"StatusCode": -1,
"ErrorMessage": "Invalid device_id. Obtain via 'Get All Devices' or 'Get a Device by Name' tool."
}
Network error response:
{
"Pid": "",
"StatusCode": 500,
"ErrorMessage": "Request timeout after 60 seconds."
}
3.2 Field Descriptions
| Field Path | Type | Description |
|---|---|---|
| Pid | string | Activity log unique identifier (Process ID). Returned on success; used to track execution status via Get an Activity Log |
| StatusCode | number | Status code. See 5.1 AB Three-Layer Error Codes |
| ErrorMessage | string | Error message. Empty string on success |
3.3 Pid Tracking
Use the returned Pid with the Get an Activity Log tool to track execution status:
| Progress Value | Meaning | Agent Action |
|---|---|---|
| Executing | Command queued or executing on device | Continue polling (interval 5-10 seconds) |
| Success | Execution succeeded | Task complete |
| Failure | Execution failed | Check the FailReason field |
| Overridden | Superseded by a newer command | No action needed |
4. Examples
4.1 Basic Example: Clear app data for troubleshooting
Request:
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"PkgId": "com.facebook.katana",
"Confirm": true,
"Reason": "User requested data reset for troubleshooting"
}
Response:
{
"Pid": "1770854462319857000",
"StatusCode": 200,
"ErrorMessage": ""
}
4.2 Advanced Example: Look up app, then clear data
Step 1: Call Get a Device App by Name to find the app's package name
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"AppName": "Chrome"
}
Response (simplified):
{
"Apps": [
{
"app_name": "Chrome",
"package_name": "com.android.chrome"
}
]
}
Step 2: Ask user for confirmation first, then call Clear App Data and Cache
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"PkgId": "com.android.chrome",
"Confirm": true,
"Reason": "Browser data cleanup for security compliance"
}
Step 3: Use the returned Pid to track status
{
"Pid": "1770854462319857000"
}
4.3 Error Example: Confirmation not provided
Request:
{
"DeviceId": "fa6edcff65ab444e8b5e0eb08df4175d",
"PkgId": "com.facebook.katana",
"Confirm": false,
"Reason": "Test operation"
}
Response:
{
"Pid": "",
"StatusCode": 200,
"ErrorMessage": "Confirm must be set to true to execute this destructive operation."
}
4.4 Error Example: Invalid device ID
Request:
{
"DeviceId": "invalid_device_id",
"PkgId": "com.facebook.katana",
"Confirm": true,
"Reason": "Clear app data"
}
Response:
{
"Pid": "",
"StatusCode": -1,
"ErrorMessage": "Invalid device_id. Obtain via 'Get All Devices' or 'Get a Device by Name' tool."
}
5. Error Handling
5.1 AB Three-Layer Error Codes
Core principle: AB uses a three-layer error code strategy. The agent should decide how to handle based on StatusCode.
| StatusCode | Meaning | Scenario | Agent Action |
|---|---|---|---|
| -1 | Parameter validation error | Local validation failed (missing required params, format error) | ❌ Do not retry; fix parameters and re-call |
| 200 | Business success or business error | HTTP request succeeded; check ErrorMessage. Upstream HTTP errors (e.g., 401/403/404) are returned as StatusCode 200 with error detail in ErrorMessage | Empty ErrorMessage = success; non-empty = business error |
| 500 | Network/request exception | Timeout, connection failure, DNS resolution failure | ⚠️ May retry (max 2 times, 5-second interval) |
5.2 Common Errors
| StatusCode | ErrorMessage Example | Cause | Fix |
|---|---|---|---|
| 200 | Confirm must be set to true to execute this destructive operation. | Confirmation not provided | Set Confirm to true |
| 200 | Reason is required for audit trail. | Reason not provided | Fill in the Reason parameter |
| -1 | Invalid device_id. | Device ID empty or invalid | Use Get All Devices to obtain a valid device ID |
| -1 | access_token is invalid. | Auth token invalid | Check credential configuration |
| 200 | API returned HTTP 404: Device not found | Device does not exist | Verify the device ID is correct |
| 500 | Request timeout after 60 seconds. | Request timeout | Retry later |
5.3 Agent Self-Healing Decision Table
| StatusCode | Auto-Retry | Retry Strategy | Manual Intervention |
|---|---|---|---|
| -1 | ❌ | - | Fix parameters and re-call |
| 200 (ErrorMessage non-empty) | ❌ | - | Fix based on error message |
| 500 | ⚠️ | Max 2 retries, 5-second interval | Escalate if persistent |
6. Best Practices
6.1 Performance Tips
- Confirm device is online: Check device status before clearing data to avoid sending commands to offline devices
- Verify app exists: Use Get All Device Apps to confirm the app is installed before attempting to clear data
- Batch operation intervals: When clearing data on multiple devices, add a 2-3 second delay between each call
6.2 Security Considerations
⚠️ High-Risk Operation Warning: This operation will permanently delete the app's local data including user settings, cached files, login sessions, and locally stored content. This action cannot be undone.
| Parameter | Note |
|---|---|
| Confirm | Must be set to true to execute; defaults to false (prevents accidental triggers) |
| Reason | Required for the audit log, e.g. "User requested data reset for troubleshooting" |
Pre-execution checklist:
- ☐ Confirm the device is online
- ☐ Confirm the correct target device and app (avoid clearing the wrong app's data)
- ☐ Verify the app package name is correct
- ☐ Notify the device holder (if applicable)
- ☐ Understand that app login sessions, settings, and local data will be lost
- ☐ Back up any important data within the app if possible
6.3 Idempotency
Idempotency: Non-idempotent. Each call triggers a new clear data command.
- Repeated calls will re-clear the app data (though subsequent calls may have no visible effect if the app has no new data)
- Avoid blind retries on timeout — instead use Get an Activity Log with the Pid to check status
6.4 Async Operation Tracking
Use the returned Pid with Get an Activity Log to track execution status:
| Progress Value | Meaning | Agent Action |
|---|---|---|
| Executing | Command queued or executing | Continue polling |
| Success | Execution succeeded | Task complete |
| Failure | Execution failed | Check the FailReason field |
| Overridden | Superseded by a newer command | No action needed |
Polling recommendations:
- Interval: 5-10 seconds
- Max polling attempts: 12 (approx. 1-2 minutes)
- On timeout: Prompt the user to manually check device status
7. Related Tools
7.1 Prerequisite Tools
| Tool | Purpose |
|---|---|
| Get All Devices | Obtain DeviceId and confirm device is online |
| Get a Device by Name | Query DeviceId by exact device name |
| Get All Device Apps | Obtain the app package name (PkgId) |
| Get a Device App by Name | Look up an app by name to get its package name |
7.2 Follow-up Tools
| Tool | Purpose |
|---|---|
| Get an Activity Log | Track clear data execution status (using Pid) |
7.3 Similar Tools Comparison
| Tool | Use Case | Difference |
|---|---|---|
| Clear App Data and Cache | Reset a specific app's data and cache | Only affects the specified app |
| Factory Reset | Wipe entire device | Erases all device data, not just one app |
| Unenroll a Device | Remove device from management | Device leaves MDM; does not clear app data |
8. Tool Chains
8.1 App Troubleshooting Pattern
Scenario: An app on a device is malfunctioning — look up the app, clear its data, and verify
Tool chain:
Get a Device by Name → Get All Device Apps → Clear App Data and Cache → Get an Activity Log (poll)
Steps:
- Call Get a Device by Name to find the device's device_id
- Call Get All Device Apps to get the list of installed apps and find the target package_name
- Ask the user for confirmation before proceeding
- Call Clear App Data and Cache with the DeviceId and PkgId
- Use Get an Activity Log with the Pid to confirm the operation completed
8.2 Shared Device Security Cleanup Pattern
Scenario: Periodically clear browser data from shared kiosk devices for security compliance
Tool chain:
Get All Devices (filter kiosk group) → [Loop] Clear App Data and Cache → Get an Activity Log
Steps:
- Call Get All Devices with Keyword={"group_name":"kiosk-devices"} to get all kiosk devices
- Ask the user for confirmation for the entire batch
- Iterate through devices and call Clear App Data and Cache for each (PkgId = com.android.chrome)
- Collect all Pid values and batch-track using Get an Activity Log
8.3 Employee Departure Device Cleanup Pattern
Scenario: An employee has left — clear sensitive app data from their assigned device
Tool chain:
Get a Device by Name → Get All Device Apps → [Loop] Clear App Data and Cache → Get an Activity Log
Steps:
- Call Get a Device by Name to find the departing employee's device
- Call Get All Device Apps to identify apps with sensitive data (e.g., email, messaging, browser)
- Ask the user for confirmation, listing the apps to be cleared
- Call Clear App Data and Cache for each target app
- Track all operations via Get an Activity Log
Appendix Reference:
- Field Reference: https://www.goinsight.ai/tools/field-reference/
- Error Code Quick Reference: https://www.goinsight.ai/tools/error-codes/
Leave a Reply.