//in onCreate btnOK.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ Action();//***run this function only once whenever push btnOK ,and when open app again run only once too Action2();//run normally }}); //----Outside public void Action(){ //action.... } public void Action2(){ //action.... }
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if(!prefs.getBoolean("firstTime", false)) { // run your one time code SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("firstTime", true); editor.commit(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)