0

How can I save the isEnabled() status (Boolean) of a Button and load it again after closing the application? I tried SharedPreferences and InternalStorage but I don't really know/understand how to use it.

4

1 回答 1

0
     SharedPreferences prefs = this.getSharedPreferences(
              "com.example.app", Context.MODE_PRIVATE);
        //To read preferences:

        boolean isEna = prefs.getBoolean("key", false); 

        //To edit and save preferences
        boolean isEnable =  true;
        prefs.edit().putBoolean("key",isEnable).commit();
于 2013-05-28T15:20:14.267 回答