开发者

sharedUserId: safe to change when app is already in market?

开发者 https://www.devze.com 2023-01-07 01:43 出处:网络
For the next version of our application, I want to change the sharedUserId since we now use an internal control dashboard app which must write to the other app\'s settings files.

For the next version of our application, I want to change the sharedUserId since we now use an internal control dashboard app which must write to the other app's settings files.

But since the 开发者_如何学运维app is already installed on many phones, will this be a problem? I ran a little test on the emulator, and I'm seeing exceptions in the device logs that *.bak versions of the preference files cannot be written. Not sure how critical that is. Curiously, safing settings still seems to work, even though the shared_prefs folder had been created using another Linux user ID.

Did anyone try this before?


And to answer my own question again:

No, it's not safe. Since updating an app via Android Market will not remove the database and preference files, the new version will not be able to read or write these files (since they were created under a different Linux user ID), and the app will crash after the update. You would have to ask your users to completely uninstall and reinstall the app, which is certainly not recommended.

As a general rule I conclude from this: Whenever you start out developing a new app, make sure to set a manual android:process and android:sharedUserId attribute! It doesn't hurt in case you don't need it, but it gives you full control over which apps have access to this app's private resources.


No solution as of now, but starring at registered issues might get Google to fix this:

http://code.google.com/p/android/issues/detail?id=1227

http://code.google.com/p/android/issues/detail?id=14074

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号