util = new SharePreferenceUtil(this, "saveUser"); mLocalActivityManager = getLocalActivityManager(); if(util.getisFirst()){ Intent intent = new Intent(MainActivity.this,WelcomeActivity.class); startActivity(intent); util.setIsFirst(false); }
SharePreferenceUtil
package com.cn.daming.deskclock.activity.util; import android.content.Context; import android.content.SharedPreferences; public class SharePreferenceUtil { private SharedPreferences sp; private SharedPreferences.Editor editor; public SharePreferenceUtil(Context context, String file) { sp = context.getSharedPreferences(file, context.MODE_PRIVATE); editor = sp.edit(); } // �Ƿ��һ�����б�Ӧ�� public void setIsFirst(boolean isFirst) { editor.putBoolean("isFirst", isFirst); editor.commit(); } public boolean getisFirst() { return sp.getBoolean("isFirst", true); } }