Clear data when switching between apps-Android

Hi ,
How can I reset when I switch between apps in my test ,the second app is open by driver.activate app ,and in the end of the test session I want to clear data to the second app(opened by the activate app) but the reset app always cleat data to first app (using app capabilities) .
The bottom line their is way to clear data to a specific up ,not just the one I started with?please share code if their is

just send pure adb command :slight_smile:
example to clear data of SMS app:

// java
            List<String> args = Arrays.asList(
                    "clear",
                    "com.google.android.apps.messaging" // clear by package name
            );
            Map<String, Object> command = ImmutableMap.of(
                    "command", "pm",
                    "args", args
            );
            driver.executeScript("mobile: shell", command);
1 Like