SQLite数据库的生命周期?当应用程序被关闭它被删除? [英] Sqlite database lifecycle? It is deleted when the app is closed?

查看:617
本文介绍了SQLite数据库的生命周期?当应用程序被关闭它被删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循一个简单的教程,创建一个类从至极扩展SQLiteOpenHelper和一张桌子和5行创建一个数据库。

I'm following a simple tutorial that creates a class wich extends from SQLiteOpenHelper and creates a DB with one table and 5 rows.

行,但我需要了解一些更多关于Android的SQLite数据库。例如,如果应用程序被关闭或发生关闭手机?在数据库中删除?

OK, but I need to understand some more about android Sqlite databases. For example, what happens if the app is closed or the phone is off? Is the database deleted?

感谢

推荐答案

当然,数据库不会被删除。我假设你正在做的正确的方式。在这种情况下,该数据库是持久的。 (当然,如果你选择在临时目录或类似那么它不会正常工作的东西来创建数据库)。

Of course the database isn't deleted. I assume you're doing it the "proper" way. In which case the database is persistent. (of course if you choose to create a database in a temporary directory or something similar then its not going to work properly).

认为它这样。该数据库基本上是一个文本文件。你在做什么到数据库修改文本文件的内容(确定它是一个稍微复杂一些在现实生活中,但其思考的好方法)。

Think of it like this. The database is basically a text file. What you're doing to the database is modifying the contents of that text file (ok its a little bit more complicated in real life, but its a good way to think about it).

一旦你做了更改数据库(例如增加了一个排)的数据库文件保存到这样的磁盘坚持它。如果手机关机或应用程序的退出则数据库文件仍然存在,你可以保持连接到它的未来。

Once you've made a change to the database (e.g. added a row) the database file is saved onto the disk thus persisting it. If the phone is turned off or the app is quit then the database file persists and you can keep connecting to it in the future.

这篇关于SQLite数据库的生命周期?当应用程序被关闭它被删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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