Created
September 14, 2022 11:05
-
-
Save dotrinh-DM/e36ac532ad766a7e6ffe7b5883391d0a to your computer and use it in GitHub Desktop.
writing log to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void log_to_internal_file(String data, Context context) { | |
try { | |
// /data/data/jp.co.xxx.G3ProRemote/files | |
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(context.openFileOutput("debug_log.txt", Context.MODE_APPEND)); | |
String timeStamp = new SimpleDateFormat("yyyy:MM:dd_HH:mm:ss").format(Calendar.getInstance().getTime()); | |
outputStreamWriter.append(timeStamp + " " + data + "\n"); | |
outputStreamWriter.close(); | |
} catch (IOException e) { | |
Log.e("Exception", "File write failed: " + e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
log_to_internal_file("abc", getContext());