android – save variables after quitting application?-ThrowExceptions

Exception or error: I want some variables to be saved, when I shut down my app and to load them after opening the app (for statistics in a game) How can I do this? EDIT: Here my code: TextView test1; String punkte = “15”; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SharedPreferences save = …

printing values of variables in logcat for debugging in android-ThrowExceptions

Exception or error: I have variables/fields in my activity which are of type float.Is there any way to log there values in logcat as Log.w,Low.v,Log.i are not helping me… How to solve: Log.d(“ADebugTag”, “Value: ” + Float.toString(myFloatVar)); ### Log.d(“tag”, “Value: ” + float); it will convert to string ### Log.d(“Value: ” + Float.toString(myFloatVar)); ### int …

android – Extending Application to share variables globally-ThrowExceptions

Exception or error: I’m trying to share two ArrayLists across the various activities in my application, using the scheme explained here: How to declare global variables in Android?. Here’s my application subclass: public class GlobalVars extends Application{ ArrayList<Player> players = new ArrayList<Player>(); ArrayList<String> playerNames = new ArrayList<String>(); public ArrayList<Player> getPlayers(){ return players; } public ArrayList<String> …

memory – public or private, does it really matter with Android variables-ThrowExceptions

Exception or error: inside of a single activity, when defining components to be used only within that activity, what’s the real difference between the following definitions: Button btnPower = null; //or private Button btnPower = null; //or public Button btnPower = null; public void somethingUsingTheButton(){ btnPower = (Button)findViewById(R.id.btnpower_id); } are there some “under the hood” …