Android(Kotlin)

SaveFile Android kotlin

----___<<<<< 2022. 5. 2. 03:17

fun saveLogAsFile(context: Context, saveText : String){

    Log.d("SDK LOG - SDKLoggingUtil : ", saveText)

    val randomUuid = UUID.randomUUID()

    val cFormat = SimpleDateFormat("hh:mm:ss")
    val currentDate = cFormat.format(Date())

    val file:String = currentDate
    val data:String = saveText
    val fileOutputStream: FileOutputStream
    try {
        fileOutputStream = context.openFileOutput("$file $randomUuid", Context.MODE_PRIVATE)
        fileOutputStream.write(data.toByteArray())
    } catch (e: FileNotFoundException){
        e.printStackTrace()
    }catch (e: NumberFormatException){
        e.printStackTrace()
    }catch (e: IOException){
        e.printStackTrace()
    }catch (e: Exception){
        e.printStackTrace()
    }

}

'Android(Kotlin)' 카테고리의 다른 글

Android Lottie  (0) 2022.05.16
android 12 splash  (0) 2022.05.15
Android REQUEST_IGNORE_BATTERY_OPTIMIZATIONS  (0) 2022.04.29
기존 Retrofit Callback 계속 붙이면?  (0) 2022.04.13
Android PeriodicWorkRequest Memo  (0) 2022.04.07