android 注销

1、在个人中心退出系统MainActivity

2、清空保存的登录数据

3、打开登录LoginActivity

 

方法:

SharedPreferencesManager.getInstance(mContext).Clear();
Toast.makeText(mContext, "注销成功,系统正在跳转!", Toast.LENGTH_SHORT).show();
mContext.startActivity(new Intent(mContext, LoginActivity.class));
MainActivity.instance.finish();

 

其中

public void Clear() {
SharedPreferences sharedPreferences = mContext.getSharedPreferences(
"ABC", Context.MODE_PRIVATE);
Editor editor = sharedPreferences.edit();
editor.clear();
editor.commit();
}

MainActity中定义:

public static MainActivity instance;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
instance = this;

}

 

posted @ 2015-09-20 14:26  jiduoduo  阅读(567)  评论(0编辑  收藏  举报