1

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 my application this folder should be assessable. No other application should be able to access this folder. Is there any method to create this. Please provide any valid link for this.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Arun
  • 95
  • 3
  • 8

5 Answers5

4

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.

Tim
  • 6,692
  • 2
  • 25
  • 30
  • 1
    Its not exactly a limitation of Android, its a limitation of FAT32. Android actually supports other formats for SD Cards such as EXT3. – slayton Mar 23 '12 at 15:35
3

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

This is not possible, sorry.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Even if we are creating a new folder it is not possible.Please reply – Arun Mar 23 '12 at 14:44
  • 2
    @user1268300: SD cards are formatted FAT32. FAT32 does not support read-only flags. That has been the case for all operating systems supporting FAT32 in the couple of decades since that filesystem was introduced. – CommonsWare Mar 23 '12 at 14:48
2

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

slayton
  • 20,123
  • 10
  • 60
  • 89
1
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.

Bigflow
  • 3,616
  • 5
  • 29
  • 52
0

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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134