Home > Mobile >  Android studio kotlin how to debug
Android studio kotlin how to debug

Time:11-10

Programming the small white, want to learn android studio kotlin, found himself can't even debug, come to help,
, such as the following code in the debug, found only debug onCreate function, set breakpoints in onDestroy function and save function place, didn't stop, but these two functions are performed? What reason is this excuse me

Package com. Example. Filepersistencetest

The import android. The content. The Context
The import androidx. Appcompat. App. AppCompatActivity
The import android. OS. Bundle
The import kotlinx. Android. Synthetic. Main. Activity_main. *
Import the Java. IO. BufferedWriter
Import the Java. IO. IOException
Import the Java. IO. OutputStreamWriter

The class MainActivity: AppCompatActivity () {


Override fun onDestroy () {
Super. OnDestroy ()
Val inputText=editText. Text. The toString ()
Save (inputText)
}
Private fun save (inputText: String) {
Try {
Val output=openFileOutput (" data ", the Context. MODE_PRIVATE)
Val writer=BufferedWriter (OutputStreamWriter (output))
Writer, use {
It. The write (inputText)
}
{} the catch (e: IOException)
E.p rintStackTrace ()
}
}
Override fun onCreate (savedInstanceState: Bundle? {
Super. OnCreate (savedInstanceState)
The setContentView (R.l ayout. Activity_main)

}
}
  • Related