Reputation: 43
I have successfully been able to save a file to my internal storage on android using the following code in java/android:
public void writeToFile(String filename) {
String code = getIntent().getStringExtra("code_full");
String fullCode = code;
try {
FileOutputStream fileOutputStream = openFileOutput(filename + ".cs", MODE_PRIVATE);
fileOutputStream.write(fullCode.getBytes());
fileOutputStream.close();
Toast.makeText(getApplicationContext(), "Saved as " + filename, Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
I do not know where I can find the saved file in my android's folders (I am trying to find it on my PC with the phone plugged in.)
Anyone know where to find it?
Upvotes: 1
Views: 114
Reputation: 3444
If you saved a file to internal storage and want a String of the path to the file, you would do getFilesDir().getAbsolutePath()
.
Upvotes: 1