GhadaSalama
GhadaSalama

Reputation: 21

Read/Write file in android

try {
                PrintStream out = new PrintStream(openFileOutput("OutputFile.txt", MODE_PRIVATE));

                str=mIn.getText().toString();
                out.println(str);
                out.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

i want to ask if this code create file called(OutputFile)?and if yes where is the path of this file??

Upvotes: 1

Views: 51

Answers (1)

Blackbelt
Blackbelt

Reputation: 157487

i want to ask if this code create file called(OutputFile)

it creates a file called OutputFile.txt

and if yes where is the path of this file??

you can retrieve its path using getFileStreamPath, which returns the file created with openFileOutput

  File file = getFileStreamPath("OutputFile.txt");
  String path = null;
  if (file != null) {
       path = file.getPath();
  }

Upvotes: 1

Related Questions