Restore apps and related data after wiping android phone
===

I developed an android app that work as admin to the device it has been installed in it. The app work as remote administrator that can do many things to the device which include wiping the data inside the device and restore it to the factory settings which means all apps that installed inside the device will be lost and also all data in sdcard will be erased too since the command that I used to do this is as follow:

    if(dpm.isAdminActive(mAdminName));
    dpm.wipeData(1);
Note:
I used 1 since I want to wipe the data and set the device to its factory settings plus delete all data in sdcard, but if I want just to reset the device to its factory settings I will use 0 instead.

My question is how Can I wipe android device and erase all data inside sdcard too with keeping my app and all its file protected from this operation which I already tried it and notice that even my app which set as admin in the device under test has been deleted.

any help in solving this issue or redirection will be completely appreciated.

regards

Husam

