Reputation: 448
I am creating a file and writing it like this:
outputStream = context.openFileOutput(symbol, context.MODE_PRIVATE);
outputStream.write(DATA.getBytes());
outputStream.close();
I can read the file from the app but I can't see the files in explorer. I need to make it visible in explorer so that it can be shared(for debugging). Also, I need the file to be in readable format (like txt) for the computer. Also, files needs to be stored in internal directory. How can I do it?
Upvotes: 2
Views: 3792
Reputation: 1082
For that you need to create a folder in external storage public directory.
Write this in manifest
<manifest>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Then you have to define a public folder in the external storage as follows :
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), albumName);
}
Here you can use DIRECTORY_PICTURES or any thing like DIRECTORY_DOCUMENTS or any thing as you wish. You can even place your own public directory instead of DIRECTORY_PICUTRES.The use of this DIRECTORY_PICTURES is that all your files saved in this folder will be read as pictures by the system.
So be careful while working with these
Upvotes: 0
Reputation: 1006539
To have your file be visible to other applications ("The file explorer of android"):
Step #1: Write to what the Android SDK refers to as external storage, such as getExternalFilesDir()
Step #2: Arrange to have the file indexed by the MediaStore
, in case your file manager is using the MediaStore
instead of the filesystem
Upvotes: 3