繁体   English   中英

将android活动状态恢复为开始状态

[英]Restoring the android activity state to the state from where it begun

我正在制作一个应用程序,在该应用程序中,我希望该应用程序进入安装到移动设备时的状态,其中包括删除所有存储的sharedpreference键和sqllite数据。 是否可以,如果可以,怎么办? 谢谢。

你可以试试看!

   FeedReaderDbHelper mDbHelper = new FeedReaderDbHelper(classname.this);
                        SQLiteDatabase db = mDbHelper.getReadableDatabase();
                        db.execSQL("delete from " + table.TABLE_NAME);
                        db.close();
                        SharedPreferences.Editor editor = sharedpreferences.edit();
                        editor.clear().commit();  

当您想以新的身份启动应用程序时发生事件,请执行以下操作。

Flush out all sqlite data
Flush out all pref data

开始您的SplashActivity

Intent intent = new Intent(this, SplashActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent); 

它将清除所有活动堆栈,您将在开始阶段访问您的应用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM