Implementation of the "logout" button callback and the button callback
@ OnClick (R. id. btn_user_logout) public void logout (View view) {// "log out" button callback method // 1. clear SharedPreferences sp = this. getSharedPreferences ("user_info", Context. MODE_PRIVATE); sp. edit (). clear (). commit (); // The data cleanup operation must be submitted. After submission, the file still exists, but the data in the file is cleared. // 2. delete file filesDir; if (Environment. getExternalStorageState (). equals (Environment. MEDIA_MOUNTED) {// determine whether the SD card is mounted // Path 1: storage/sdcard/Android/data/package name/files filesDir = this. getExternalFilesDir ("");} else {// internal storage of the mobile phone // path: data/package name/files filesDir = this. getFilesDir ();} File file = new File (filesDir, "icon.png"); if (file. exists () {file. delete (); // delete objects in storage} // 3. destroy all activities this. removeAll (); // 4. re-enter the home page this. goToActivity (MainActivity. class, null );}