Попробуйте это
public class TestActivity extends Activity {
private SharedPreferences sharedPrefs;
private Editor prefsEditor;
private static final String APP_SHARED_PREFS = "com.demo.test.Login_preferences";
private static final String APP_CHOICE = "Choice";
private static final String APP_DESIGN = "Design";
private static final String APP_DEVEL = "Develop";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharedPrefs = getSharedPreferences(APP_SHARED_PREFS,
Context.MODE_PRIVATE);
String choice = getValueforKey(APP_CHOICE);
if(choice.length() == 0){
setContentView(R.layout.main);
Button design = (Button) findViewById(R.id.des);
Button dev = (Button) findViewById(R.id.dev);
design.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
saveKey(APP_CHOICE,APP_DESIGN);
Intent intent = new Intent(TestActivity.this , Design.class);
startActivity(intent);
finish();
}
});
dev.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
saveKey(APP_CHOICE,APP_DEVEL);
Intent intent = new Intent(TestActivity.this , Develop.class);
startActivity(intent);
finish();
}
});
}else if(choice.equals(APP_DESIGN)){
Intent intent = new Intent(this , Design.class);
startActivity(intent);
}else if(choice.equals(APP_DEVEL)){
Intent intent = new Intent(this , Develop.class);
startActivity(intent);
}
}
public String getValueforKey(String Key)
{
this.sharedPrefs =getSharedPreferences(APP_SHARED_PREFS,
Context.MODE_PRIVATE);
return sharedPrefs.getString(Key, "");
}
public void saveKey(String Key, String value) {
this.sharedPrefs = getSharedPreferences(APP_SHARED_PREFS,
Context.MODE_PRIVATE);
this.prefsEditor = sharedPrefs.edit();
prefsEditor.putString(Key, value);
prefsEditor.commit();
}
}