How can I create an app which deletes itself?

179 Views Asked by At

How can i write a function that can remotely self-destruct it, ie delete that application from the phone?

Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.example.myapplication"));
startActivity(intent);

This code does not work on Android 10+

1

There are 1 best solutions below

1
Sandeepa_Dilshan On

You can purge application files by enumerating app directory and deleting everything in there plus removing your application files on SD card. Uninstalling application itself is a different beast altogether. Non system apps cannot do that AFAIK (starting from android 2.0?).