Reputation: 3052
I am writing a log data to the File in android. But I am unable to understand where this file is stored on my android device ( google nexsus 7 ). Where and How should I look for the contents of the file ?
Following is the piece of code I am using to write log data to the file.
public File AppendingLog(String LogData){
try {
File logFile = new File(Environment.getExternalStorageDirectory(),
"yourLog.txt");
if (!logFile.exists()) {
try {
logFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
BufferedWriter buf = new BufferedWriter(new FileWriter(logFile,
true));
buf.append(LogData);
buf.newLine();
buf.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return logFile;
}
Upvotes: 0
Views: 38
Reputation: 591
I think answers below are what you need.
You can also download Astro File Manager App which will also give you an idea where your files go on Android System.
Upvotes: 0
Reputation: 12919
On most devices, it will be in /sdcard/
. The exact path will be /sdcard/yourLog.txt
.
As you are using Environment.getExternalStorageDirectory()
, the actual path will differ between devices. Some devices return the external sd card path, but most will return the internal sd card's path, which usually is /sdcard/
.
Upvotes: 1