[Solved] How do I make my App Open Only Once and the next time I open the app it will crash?


I think SharedPreferences is the better idea and the data is more secure than a file.

Simply copy paste this to your onCreate().

SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
Boolean expired= sharedPref.getBoolean("expired", false);

if (expired){
    throw new RuntimeException("Custom crash");
}

//Make it expierd
SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean("expired", true);
editor.commit();

1

solved How do I make my App Open Only Once and the next time I open the app it will crash?