0% found this document useful (0 votes)
15 views11 pages

The Different Data Storage Options Available On Android:: Pairs

The document discusses different data storage options available on Android including Shared Preferences, SQLite databases, and Firebase. Shared Preferences store private key-value pairs and are application specific. SQLite provides support for local databases, while Firebase offers a real-time cloud database.

Uploaded by

Rahul Bhati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views11 pages

The Different Data Storage Options Available On Android:: Pairs

The document discusses different data storage options available on Android including Shared Preferences, SQLite databases, and Firebase. Shared Preferences store private key-value pairs and are application specific. SQLite provides support for local databases, while Firebase offers a real-time cloud database.

Uploaded by

Rahul Bhati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

The different data storage options available on Android:

1. Shared Preferences: Store private primitive data in key-value


pairs.

2. Databases: Store structured data in a private database.

(a). SQLite: Android provides full support for SQLite databases. Any
database you create is accessible only by your app.
The data is not naturally accessible to other apps.

(b). Firebase: It is Google’s mobile platform that provides real time


database.
SharedPreferences:

1. Similar to a Map i.e. Key-Value pairs.


2. Android stores Shared Preferences setting as XML file.
3. It is application specific.

Modes:

● MODE_PRIVATE
● MODE_APPEND
● MODE_WORLD_READABLE
● MODE_WORLD_WRITABLE
Initialization:
SharedPreferences pref =
getApplicationContext().getSharedPreferences("MyPref",Context.MODE_P
RIVATE);

Editor editor = pref.edit();

Storing data:
editor.putString("key_name", "string value"); // Storing string
editor.putInt("key_name", "int value"); // Storing
integer

editor.commit(); // commit changes


Retrieving Data:
pref.getString("key_name", null); // getting String

pref.getInt("key_name", -1); // getting Integer

Clearing or Deleting Data:


editor.remove("name"); // will delete key name

editor.remove("email"); // will delete key email

editor.commit(); // commit changes


What is Firebase?
Firebase is a powerful platform for your mobile and web
application. Firebase can power your app’s backend, including
data storage, user authentication, static hosting, and more. With
Firebase, you can easily build mobile and web apps that scale
from one user to one million.

You might also like