jl90
jl90

Reputation: 649

Where to find file that is written by FileOutputStream?

I am trying to use FileOutputStream to create a text file that will write data into it (saving to internal storage). However, it doesn't even generates the text file. I tried finding the text file using DDMS every single time I test run my codes but it's not there. I can't find the package name folder in the /data/data directory. I am clueless why it is not working as Eclipse didn't complain about any errors with my code too.

Code:

public void saveGroup(String grpName)
{
    try
    {
        FileOutputStream fos = openFileOutput("data.txt", MODE_PRIVATE);
        OutputStreamWriter osw = new OutputStreamWriter(fos);

        Team newTeam = new Team(grpName, memberList);
        String s = newTeam.name + "|" + newTeam.getMembers();

        osw.write(s);
        osw.flush();
        osw.close();

        invalidCharacterToast("Saved");
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
}

**Team is a class that I have created myself.

Upvotes: 0

Views: 1896

Answers (1)

pdriegen
pdriegen

Reputation: 2039

As per the Android Documentation on openFileOutput, it creates a private file for writing. If you are using the emulator, you will see the file in /data/data/< packagename >/files folder. On the other hand if you're using a physical, non-rooted device, this area is inaccessible via DDMS.

Have you tried reading the file after writing it via openFileInput?

Upvotes: 2

Related Questions