Search code examples
javaandroidsd-card

Logging on SD-card in Android


How can we save log-file of our application actions on SD-card?

We should have a file created everyday:

  • the name of the file should have a date format
    • file name should be current date

Solution

  • Environment.getExternalStorageDirectory().toString() use this to get the path of SD card and then get today's date, convert it to string and concat it with SD card path. Use the concatenated string to create a File and write your log using FileOutputStream or FileWriter.