Skip to main content
Participant
June 17, 2011
Answered

SecurityError: fileWriteResource, How to make a file in sdcard?

  • June 17, 2011
  • 1 reply
  • 1137 views

Hi. I want to make a file in sdcard but air fail and return "SecurityError: fileWriteResource".

I set file's permission with "WRITE_EXTERNAL_STORAGE".

Why don't make a file?

It is impassible with air in android?

Please tell me about the reason.

Thanks.

This topic has been closed for replies.
Correct answer DavidSaracino

It's hard to say without looking at your code but here's a snippet that works.  Creates a file at "/sdcard/MyNewFile.txt".

--------

var fileName:String = "MyNewFile.txt"

var saveFile:File = File.documentsDirectory;

saveFile = saveFile.resolvePath(fileName);

var fileStream:FileStream = new FileStream();

fileStream.open( saveFile, FileMode.WRITE );

fileStream.writeUTFBytes( "some text" );

---------

Also, make sure you don't have your SD Card mounted on your computer as "USB Mass Storage".  You won't be able to access from your app it if it's mounted.

If you still can't get it working, please post a code snippet.

-David

1 reply

DavidSaracinoCorrect answer
Participating Frequently
June 19, 2011

It's hard to say without looking at your code but here's a snippet that works.  Creates a file at "/sdcard/MyNewFile.txt".

--------

var fileName:String = "MyNewFile.txt"

var saveFile:File = File.documentsDirectory;

saveFile = saveFile.resolvePath(fileName);

var fileStream:FileStream = new FileStream();

fileStream.open( saveFile, FileMode.WRITE );

fileStream.writeUTFBytes( "some text" );

---------

Also, make sure you don't have your SD Card mounted on your computer as "USB Mass Storage".  You won't be able to access from your app it if it's mounted.

If you still can't get it working, please post a code snippet.

-David