Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.SharedPreferences; import android.media.AudioManager; import android.preference.PreferenceManager; public class Main { private static final String VivaVolume = "VivaVolume"; public static int getVivaVolume(Context context) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int amStreamMusicVol = am.getStreamVolume(AudioManager.STREAM_MUSIC); return getPreferences(context).getInt(VivaVolume, amStreamMusicVol); } /** * Default Preference Helper * @param context - the calling application context. * @return Shared Preferences */ private static SharedPreferences getPreferences(Context context) { return PreferenceManager.getDefaultSharedPreferences(context); } }