Its all in the DateUtils class.
CharSequence getRelativeTimeSpanString (long time, long now, long minResolution);
gives you the difference between time and now in a format like:
54 seconds ago.
To use your date string you have to convert it into empoch time first:
String mytime = pref.getString("announcementtime" + count, null);
// it comes out like this 2013-08-31 15:55:22 so adjust the date format
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = df.parse(str);
long epoch = date.getTime();
String timePassedString = getRelativeTimeSpanString (epoch, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS);