SharedPreferences prefs = getSharedPreferences("myPrefs", MODE_PRIVATE); long score = prefs.getLong("score", 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); long lastUpdated = prefs.getLong("lastUpdated", 0);In this example, the getLong method is used to retrieve the long value associated with the key "lastUpdated" from the default shared preferences object. If the key doesn't exist, the default value of 0 will be returned. The package library for this method is android.content.SharedPreferences.