Some questions about "DONT_DELETE_DATA" , how it works, and how do apps use it

402 Views Asked by At

Background

I'm developing an app-manager app, and I've noticed that there is a way to get a list of "uninstalled apps" (using "GET_UNINSTALLED_PACKAGES" flag) , which are apps that requested to avoid removal of their data upon uninstallation .

Here's what the documentation says:

Flag parameter to retrieve some information about all applications (even uninstalled ones) which have data directories. This state could have resulted if applications have been deleted with flag DONT_DELETE_DATA with a possibility of being replaced or reinstalled in future.

Note: this flag may cause less information about currently installed applications to be returned.

The problem

I've tried to investigate more about this feature, but I didn't find almost anything about it, other than this documentation.

The questions

  1. How do such apps request this feature? I can't even find the "DONT_DELETE_DATA" anywhere on the documentation except for what I've written about. Looking on this website, it seems it's a part of the PackageManager class, but I can't see it being public on Eclipse.
  2. How long will the data stay?
  3. How can I detect such apps? Is there anything to look at PackageInfo or ApplicationInfo that shows it? Is it "FLAG_INSTALLED" on the ApplicationInfo, perhaps? I've run it, and none of the list of apps that I got have this flag turned off, even though I've installed and uninstalled many apps.
  4. Would choosing to uninstall such "ghost"-like apps really remove them?
  5. Will I still be able to see those apps on the built in app-manager?
  6. Will I still be able to manage such apps?
  7. What information can be retrieved of such apps (icon, name, etc,... )? I ask this since the documentation say "this flag may cause less information" .
  8. The documentation say that when I use GET_UNINSTALLED_PACKAGES I might get less information about "currently installed applications". Is it a mistake? shouldn't it be "currently un-installed applications" ?
  9. When an app uses this flag of not removing its data, does it mean only internal-storage, private data, or also external-storage, public data ?
1

There are 1 best solutions below

2
On

According to the source code at https://github.com/android/platform_frameworks_base/blob/master/core/java/android/content/pm/PackageManager.java, PackageManager has a deletePackage method which takes flag parameters.

DONT_DELETE_DATA is one of those flags. So, this is not an attribute of an application, it's a flag to the deletePackage method to tell it to preserve the data while removing an application.

You don't see deletePackage in the javaDocs because the method has a @hide tag.