2

I am downloading xml file from local host to SD card. I want to store that XML in invisible mode or hidden file. i dont know how to store hidden file file directly to SD card. can anyone guide me how to store hidden files..

RAAAAM
  • 3,378
  • 19
  • 59
  • 108

1 Answers1

4

MODE_PRIVATE will create the file (or replace a file of the same name) and make it private to your application.

String FILENAME = "hello_file";
String string = "hello world!";

FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

But this will store the file on the phone storage. You can't make private file on the sd card because every application has access to the sd card will the same privileges.

Mojo Risin
  • 8,136
  • 5
  • 45
  • 58
  • Thank you, but i need to store my file in SD card as hidden mode. i tired context.modeprivate, but it getting error. This code is not works through sdcard. do you have any idea about same thing on sdcard... – RAAAAM Mar 30 '11 at 06:39
  • 1
    By hidden if you mean just to be hidden you can named it ".my_file". On unix all files that start with "." are hidden but still all who have access to the sd card can modify it. Maybe this thread will help you http://stackoverflow.com/questions/1129644/how-to-make-a-file-hidden-in-android-sd-card – Mojo Risin Mar 30 '11 at 07:09
  • As an aside, Context.MODE_PRIVATE doesn't seem to be required. "By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user)." – Learn OpenGL ES Nov 16 '12 at 13:23