如题,已经添加了<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在创建文件时还是有异常提示没有权限,为什么?

解决方案 »

  1.   

    对应Android 1.5以上的版本中一定要在AndroidManifest.xml中加入:<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
    并且你要确认你的SD卡的读写权限打开的。然后
    写入SD卡:File f = new File(android.os.Environment.getExternalStorageDirectory()+"/test.txt");
    String str="this is a test about Write SD card file";写入方法:
    FileOutputStream fileOS=new FileOutputStream(f);
    fileOS.write(str.getBytes());
    fileOS.close();
    BufferedWriter buf = new BufferedWriter (new OutputStreamWriter(fileOS));
    buf.write(str,0,str.length());
    buf.flush();
    buf.close();
      

  2.   

    SD卡对system用户没有读写的权限,你可以用 ls -l查看一下,如下:
    d---rwxr-x system   sdcard_rw          2010-07-26 12:56 sdcard
     我也在被这个问题困扰着,期待高人能找到方法
      

  3.   

    只要<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    就可以了,不需要加上android.uid.system,如果加了这个,就肯定是没有权限读写的。 
      

  4.   

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    只加上这个就行不需要android.uid.systemd---rwxrwx system   system            2010-07-28 11:11 sdcard
    这是sdcard的权限读写都可以的
      

  5.   

    学习,另外请教下:
    1.假如我现在一个app需要获得系统权限,就是说要加上android.uid.system,同时想能读写sdcard卡,该如何实现呢!?
    2.另外如何看一个app是运行在哪个uid下的?没有源码情况下。
      

  6.   

    一帮傻逼,android.uid.system是前提,自己去试试,别瞎扯淡,真无耻
      

  7.   

    请问:
     1.假如我现在一个app需要获得系统权限,就是说要加上android.uid.system,同时想能读写sdcard卡,该如何实现呢!?
    这个问题解决了吗?
    Setings中就是这种情况
      

  8.   

    谁解决了android.uid.system能读写sdcard的问题啊,我也遇到了这个难题
      

  9.   

    我也遇到需要system权限的时候,却不能读写sdcard的问题!!!
      

  10.   

    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. 从上面可以看出,system process是不允许操作sdcard的,有个办法是,可以借助一个运行在user process中的activity helper类完操作sdcard的动作