简体   繁体   中英

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

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 .

In that case i suggest usage of XML files. Pretty simple to save and load data.

Build class that will take care of all XML routine. Each time you want to save you activy, just call for appropriate method in this class. Method will prepare all data you need, and create file based on date you required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM