First Love

The first phone I ever got was a Motorola Startac 70. This was back in 98 or so, a flip phone and I still remember it ever so clearly!

I’m pretty sure my next phone was an A1000, a pretty awesome phone. This was around the time that Motorola started releasing the razr which I was far from impressed with. I jumped ship to Sony Erricson and I went through a couple of those before heading over to the wonderful world of HTC. I wanted a smart phone to help with work and so on and I got the HTC HD (If I recall) which was a Windows phone.

While this make me uncomfortable, I was still more comfortable with this than a blackberry. I couldn’t get an iPhone for some reason that I cannot remember.

The phone was pretty laggy and I got pretty sick of it pretty quick. I then got myself my first android phone – an HTC Hero… Most people didn’t like the curvy bit at the bottom but I didn’t care. I was happy to be on the cutting edge. It was also a bit slow and laggy. but it was android and I loved it. It started a brand new love affair… Let me tell you more…

Continue reading

Android – Managing Global Configuration

The Problem

Accessing preferences / configuration / settings from Android is actually pretty straightforward as long as you are in an Activity. To read:

// PREFS_FILENAME = "nameOfPrefsFile";

SharedPreferences pref = getSharedPreferences(PREFS_FILENAME,

String string = pref.getString("key", "default");
// 1 is the default if key isn't set
int intValue = pref.getInt("intKey", 1); 

// and so on

SharedPreferences is the key class. To write, you also need the SharedPreferences.Editor class, as follows:

// PREFS_FILENAME = "nameOfPrefsFile";
SharedPreferences pref = getSharedPreferences(PREFS_FILENAME,
Editor editor = pref.edit();
editor.putString("key", "value");
editor.putInt("intKey", 5);  

// Until you call commit, the changes will not
// be written, so don't forget this step

In general however, you will need access to settings in more than one activity and it seems a bit wasteful to get these bits littered through the application. Since I am lazy and like to write things just once, I  separated all the prefs stuff into one class called Settings.

Continue reading