清除缓存和数据后,Android重新启动应用程序

编程入门 行业动态 更新时间:2024-10-27 07:22:55
本文介绍了清除缓存和数据后,Android重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个需要清除数据才能再次运行的应用程序. 我正在使用此清除数据,

I have an app which requires data cleaning to work better again. I am clearing data using this,

((ActivityManager)MainActivity.this.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData();

但是无法重新启动应用程序.我尝试在清除数据后添加意图.但是由于应用程序在清除数据后关闭.我认为该代码无法访问.

But cannot restart the app. I tried adding intent after clearing data. But since the app closes after clearing data. I think that code is unreachable.

((ActivityManager)MainActivity.this.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData(); Toast.makeText(MainActivity.this,"Reloading...",Toast.LENGTH_SHORT).show(); startActivity(new Intent(MainActivity.this,MainActivity.class)); finish();

推荐答案

调用clearApplication数据后,应用程序被杀死.这就是为什么MainActivity不被调用的原因.

After calling clearApplication data, application is killed.Thats why MainActivity doesn't called.

更多推荐

清除缓存和数据后,Android重新启动应用程序

本文发布于:2023-10-17 13:23:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1501050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   缓存   应用程序   数据   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!