Reputation: 908
Can sharedUserId
provide access to files in the data/data/com.example/files dir?
I tried to do that, and I can retrieve the context and check if this dir is exists, although when I trying to read files from it the debuger gives me PERMISSION DENIED error.
They say in documentation that SharedUserId
provides shared access to data and even can run two apps in the same process, what is the data about what they are saying? Can it be that this feature gives only access to 'static' resources of the application and not to the ones that have been created dynamically?
UPD
fw_context = createPackageContext("com.example", Context.CONTEXT_IGNORE_SECURITY);
String[] str = fw_context.getFilesDir.list();//str=null
As I have commented, the str
here is null
, I don't know why it's null
, but I know that there is some files in this dir (I have rooted phone so I can see this)
Upvotes: 2
Views: 694
Reputation: 1006614
Can sharedUserId provide access to files in the data/data/com.example/files dir?
Yes, if and only if:
Both apps have the same non-empty sharedUserId
value
Both apps have always had the same non-empty sharedUserID
value (i.e., you cannot update an app from not having sharedUserId
to having a sharedUserId
)
Both apps are signed by the same signing key
That being said, sharedUserId
is almost never the right answer, for the simple reason that neither app will know about what the other app is doing with the files. Use a ContentProvider
(or some other form of IPC) to share content between apps, using signature
-level permissions or other identity checks to ensure that only the right apps can interact over the IPC channel.
Upvotes: 4