Back to project page ABTester.
The source code is released under:
MIT License
If you think the Android project ABTester listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package ab.tester.prefs; /*from w w w. ja v a 2 s.c o m*/ import java.util.Random; import android.content.Context; import android.content.SharedPreferences; public class ABGeneralSharedPrefs extends ABSharedPrefs { public static final String PERCENTILE = "percentile"; public ABGeneralSharedPrefs(Context context) { super(context); } @Override protected String getPrefsName() { return "ABTester_general"; } public int getPercentile() { int random; if (prefs.contains(PERCENTILE)) // use old random number random = prefs.getInt(PERCENTILE, 0); else { random = new Random().nextInt(100); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(PERCENTILE, random); // first time, save it apply(editor); } return random; } }