Create a read-only folder in sdcard in android

前端 未结 5 1638
无人共我
无人共我 2020-12-21 19:14

I want to create a folder in sdcard in an android device and I want to set a folder permission for the creating folder. The folder permission should be that from only from m

相关标签:
5条回答
  • 2020-12-21 19:39

    as others have said, you can't for the reasons specified.

    i'm not exactly sure what you are trying to accomplish, but if you want to create a private file that can't be accessed by other apps, you can create in your app's "data" directory, by doing this,

    OutputStream os = context.createFileOutput("myfile.ext", Context.MODE_PRIVATE);
    

    note that this is not the SD card, it's internal storage, so you aren't going to be able to create a very large file.

    0 讨论(0)
  • 2020-12-21 19:41
    String SaveFolder = "/Ready";
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File myFolder = new File(extStorageDirectory + Folder);
    myFolder.mkdir();
    

    This is a code to make a folder, and just like Tim said: it is not possible to create read-only permissions folder.

    0 讨论(0)
  • 2020-12-21 19:49

    sadly it is not possible to create read-only permissions for the sdcard. This is a part of Android's system design and won't be changed soon.

    0 讨论(0)
  • 2020-12-21 19:52

    I am making an application in android and I want to make a ready only folder in sdcard.

    This is not possible, sorry.

    0 讨论(0)
  • 2020-12-21 19:55

    FAT32, the standard SD card file system, does not support file permissions. This means that any file is world readable and world writeable.

    0 讨论(0)
提交回复
热议问题