在AndroidManife.xml 中添加android
android:sharedUserId="",ui
能夠將不一樣的程序加入到同一個進程中,方便數據的共享。xml
但必需要知足一個條件,即:共享UserId的程序必須使用相同的簽名。進程
在AndroidManifest.xml中聲明get
android:sharedUserId="android.uid.system"後,it
意味着將本身的程序加入到了系統的進程中,同時也將得到極大的權限。io
遺憾的是該應用程序將沒有權限讀寫SD卡。file
Processes that continue holding open fds on the sdcard a little after it is
requested to be unmounted will be killed so that it can unmount.
We don't want the system process to be able to access the sdcard to avoid
these kinds of issues (and just general security cleanliness), so that it
does not have permission to access it. 權限
The system user can not access the SD card, because if the SD card gets unmounted it may need to kill any processes that have files open on it and we don't want system processes being killed like that. If you want to access the SD card, you need to not use the system shared user ID.request
解決方法:
須要用到android:sharedUserId="android.uid.system"能夠作成一個服務,
或者把SD卡操做的功能獨立出去,作成一個服務。