Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does an Android SQLite database persist after switching the device off?

Tags:

android

sqlite

I want to develop an Android app. I would like to get the input from user and store it in the phone's database.

My data should be retained in the phone even if the phone gets switched off. Is this possible using an SQLite database?

like image 516
Mahe Avatar asked Mar 13 '13 05:03

Mahe


People also ask

Where SQLite database is stored in Android?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.

Does SQLite run in the background?

All SQLite operations do not need to be on a background, but should be. Even simple row updates can impact the UI thread and therefore application responsiveness. Android includes the AsyncQueryHandler abstract class: A helper class to help make handling asynchronous ContentResolver queries easier.

Is SQLite offline or online?

SQLite is an offline database that is locally stored in the user's device and we do not have to create any connection to connect to this database.


2 Answers

Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires

Your data storage options are the following:

Shared Preferences Store private primitive data in key-value pairs.

Internal Storage Store private data on the device memory.

External Storage Store public data on the shared external storage.

SQLite Databases Store structured data in a private database.

like image 195
DjHacktorReborn Avatar answered Oct 13 '22 01:10

DjHacktorReborn


I would like to get the input from user and store it in the phone database(for which sqlite is used). I would like to know , if I can prefer to build my app using sqlite database. My data should be retained in the phone even if the phone gets switched off. Is it possible using sqlite database?

Yes you can Use sqlite Database.

But, if you have data like one or two String then you should Go with SharedPreferences

Hope it Will Help.

like image 27
Bhavesh Patadiya Avatar answered Oct 12 '22 23:10

Bhavesh Patadiya