检测时,应用程序被关闭 [英] detect when application is closed

查看:83
本文介绍了检测时,应用程序被关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当应用程序被关闭,因为我需要删除一个数据库,当用户关闭应用程序,只是在那一刻,当用户关闭该应用程序是合适的时机删除SQLite数据库,我怎么能检测呢?

I want to know when the app is closed, because i need to erase a Database when the user shutdown the app, just in the moment when the user close the app is the right moment to erase the SQLite Database, how can i detect this?

推荐答案

假如你不这样做完成()您的主要活动,清除您的数据库中的<$ C该活动的$ C>的onDestroy()方法可能是最接近你想要完成的任务的。正如已经指出的评论,指的http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle.

Supposing you don't finish() your main activity, clearing your database inside the onDestroy() method of that activity might be the closest of what you want to accomplish. As has been pointed in the comments, refer to http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle.

这篇关于检测时,应用程序被关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆