Reputation: 399
Where should the CSV output text file from my Android App (writing in Eclipse) be stored. I currently use:
> File peopledetail_file = new File(this.getFilesDir(),
> "PeopleDetailsFile");
and
InputStream filestream = openFileInput("PeopleDetailsFile");
to access my file. This clearly does not work, as I get an error, saying it can't be found at this location
/data/data/com.example.partyorganiser/files/PeopleDetailsFile
Upvotes: 0
Views: 132
Reputation: 375
For Creating a file you must call peopledetail_file.createNewFile()
then write your file
File peopledetail_file = new File(this.getFilesDir(), "PeopleDetailsFile");
peopledetail_file.createNewFile();
FileOutputStream fos = new FileOutputStream(peopledetail_file);
// do writing ...
PrintWriter pw = new PrintWriter(fos);
pw.print("Hello");
pw.flush
fos.flush();
fos.close();
Upvotes: 1
Reputation: 1006819
If you are going to use openFileInput()
, use openFileOutput()
.
If you are going to use getFilesDir()
for output, use getFilesDir()
for input.
Upvotes: 1