tags:

views:

60

answers:

2

A question about the internal storage that's private to each application (especially when storing files with Context.MODE_PRIVATE).

How is that storage actually assigned to the application? Just by package name or also somehow bound to the sign key of the app?

Let's say I have installed application 1 and then write another application 2 with the same name and package name (just differently signed with different keys) and install it (app 2 replacing app 1), would that application 2 get access to the /data/data/[app]/files ?

Or would I not even be able to replace app1 with app2 due to different sign keys in the first place?

+1  A: 

I don't think you can have 2 applications with the same package. I know if I have a development build on my device and I try to install the release, I get an error and I MUST uninstall the previous first.

This also coincides with pm, which uninstalls, and lists applications by the package name.

So my answer is that it assigns it based on the package name, but you can't have 2 applications with the same package name.

Ryan Conrad
Ok, so if you have your development build installed, how does the PM then distinguish on another installation attempt whether it's an updated development build or a release build?Since name and package name are the same, that could only happen through the key you sign your app with, right?Cause if you'd be updating an existing development build with a new development build, you don't need to uninstall the apk manually. This, the PM is doing for you.
Mathias Lin
yes, it does see that it is signed different, but that's the point, you can't have 2 applications with the same package name installed on the device. because if it was signed the same, it would overwrite it, and since it's different, it has to be removed, manually. PM does not automatically remove it, and when you update, it also does not automatically uninstall, it just overwrites the apk.
Ryan Conrad
+1  A: 

Just by package name or also somehow bound to the sign key of the app?

Neither.

Each application, when installed, is assigned a Linux user ID. All of its files are owned by that user. Its process runs as that user. MODE_PRIVATE files are set to deny-all for other users.

Or would I not even be able to replace app1 with app2 due to different sign keys in the first place?

Correct.

CommonsWare