在我的应用程序中设置"android.uid.system"后,它无法访问SD卡?

Jud*_*udy 4 android android-manifest android-emulator

这是一个奇怪的问题.如果我没有设置android.uid.system,我的应用程序可以成功访问SD卡.但设置后android.uid.system,我的应用程序无法访问SD卡.此时,发生异常:07-13 09:11:24.999: INFO/System.out(9986): create file happen exception--->java.io.IOException: Permission denied.我检查我在正确的地方写了正确的权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />. 
Run Code Online (Sandbox Code Playgroud)

因为forceStopPackage在我的应用程序中使用,我需要添加android.uid.system到清单中.我已经LOCAL_CERTIFICATE := platform在make文件中写了.谁能解释这个奇怪的问题.设置完成后android.uid.system,我的应用程序属于系统进程,应该有更多的权限来访问SD卡.这是我的想法.以下是我的代码:

public void setPackage(String dir){

        System.out.println( "setPackage dir=="+dir  );
        File share=new File("/mnt/sdcard","test.txt");
        if(!share.exists()){
             try{
            share.createNewFile();

        }catch(Exception e){
            System.out.println( "creat file happen exception--->" +e.toString() );
        }
      }
         try{
           if(share!=null){
                System.out.println( "create file is not null"  );
                    FileOutputStream fops=new FileOutputStream(share);

                    fops.write(dir.getBytes());
                    fops.flush();
                    fops.close();
        }
        }catch(Exception e){
                System.out.println( "write Exception-->" +e.toString() );
        }

    }
Run Code Online (Sandbox Code Playgroud)

我的应用程序在模拟器上运行,目标版本为2.3.非常感谢你.

Jud*_*udy 5

请阅读:link1

和这个link2