I am trying this simple save .txt on an Android phone but I can't find the file with ddms->file explorer; Data folder is empty/not expandable (so data/data/[package name]/files is not shown). Also on my Android device (moto G) I can't find the file. But the log shows the file should be saved :
saveBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Create a file in the Internal Storage
String fileName = "MyFile.txt";
String content = "hello world";
FileOutputStream outputStream = null;
try {
storageDir = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
),
getAlbumName()
);
outputStream = openFileOutput( fileName, Context.MODE_PRIVATE);
outputStream.write(content.getBytes());
outputStream.close();
Log.d(SAVE_PROCESS, "File directory: "+storageDir +" File name: "+fileName + " directory "+getFilesDir());
} catch (Exception e) {
e.printStackTrace();
Log.d(SAVE_PROCESS, "File not saved");
}
}
});
}