Nullptr
Nullptr

Reputation: 3183

In Android, where is the default directory when I write a file?

In a Java-based Android application on a production device (USB debugging is enabled, so I can adb shell), I wrote a file something like:

BufferedWriter writer = new BufferedWriter(new FileWriter("log.txt"));

But I can't easily find the location of log.txt. Where can I find it?

And a follow-up question: what is a recommended directory for such writing a log/debug file?

Upvotes: 1

Views: 552

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

Where can I find it?

You can't. Your code crashed, because you did not provide a fully-qualified path.

Use File objects pointing to valid locations on internal storage or external storage.

what is a recommended directory for such writing a log/debug file?

Usually, we log to LogCat, using methods on the Log class.

Upvotes: 1

Related Questions