Writing Text to Internal Storage

  • Replies:0
Mark Barr
  • Forum posts: 4

Mar 13, 2014, 1:04:55 AM via Website

Guys

Excuse my ignorance nut im prettyy new to this

Im trying to write a string to a text file on the phone internal storage

i use the following code

protected void writefile() {
String FILENAME = "filedemo.txt";
String content = txtMessage.getText().toString();

try {
FileOutputStream fos = openFileOutput(FILENAME,MODE_PRIVATE);
fos.write(content.getBytes());
fos.close();
Toast.makeText(this, "File Saved",Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}

I understand this writes it to the internal storage in data/data but I want it to store in a folder called "Datafiles" which I can access via my PC or using a file manager

any ideas how i do this?

Your help greatly appreciated

Mark

Emma Lokko

Reply