0% found this document useful (0 votes)
18 views

Tutorial 9 (2)

The document outlines various app data storage options in the Android framework, including app-specific storage, shared storage, preferences, and databases, each serving different purposes based on data sensitivity, size, structure, accessibility, persistence, and performance. It discusses the use of multiple storage types within applications, providing examples of social media and weather apps. Additionally, it compares cache data, SharedPreferences data, and save instance state data in terms of purpose, persistence, storage location, use case, accessibility, and lifetime.

Uploaded by

Adib Rusyaidi
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)
18 views

Tutorial 9 (2)

The document outlines various app data storage options in the Android framework, including app-specific storage, shared storage, preferences, and databases, each serving different purposes based on data sensitivity, size, structure, accessibility, persistence, and performance. It discusses the use of multiple storage types within applications, providing examples of social media and weather apps. Additionally, it compares cache data, SharedPreferences data, and save instance state data in terms of purpose, persistence, storage location, use case, accessibility, and lifetime.

Uploaded by

Adib Rusyaidi
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/ 3

1.

Briefly explain the following App Data Storage


available in the Android Framework:
a) App-Specific Storage

App-specific storage refers to storing data that is private to the application. This data is stored in
either:

●​ Internal Storage: Private to the app and inaccessible to other apps.


●​ External Storage: Stored in app-specific directories but can be accessed with the right
permissions.

Examples: Saving files in the files or cache directories.​


Use Case: Ideal for sensitive data that should not be shared with other apps.

b) Shared Storage

Shared storage is used for storing data that can be accessed by other apps or the user.

Examples: Media files (photos, videos, audio) and documents stored in shared directories like
Downloads or Pictures.​
Permissions: Apps need specific permissions to read/write to shared storage.

c) Preference

Preferences store small amounts of key-value pairs, typically user settings or preferences.
Managed using SharedPreferences.

Examples: User preferences, app settings, or flags.​


Storage: Data is stored in an XML file.​
Use Case: Lightweight storage solution for simple data.

d) Database

Databases store structured data in a persistent manner. The most common database used is
SQLite.

Examples: User profiles, transaction history, or app content.​


Use Case: Ideal for storing complex data that requires querying.
2. Considerations When Choosing an App Data Storage
Type
When selecting a storage type, consider:

1.​ Data Sensitivity – Sensitive data (e.g., credentials) should be stored in app-specific
storage or encrypted databases.
2.​ Data Size – Small data fits in SharedPreferences, while large data suits databases
or file storage.
3.​ Data Structure – Use databases for structured data and file storage for unstructured
data (e.g., media files).
4.​ Data Accessibility – Private data should use app-specific storage, while shared data
requires shared storage.
5.​ Persistence – Decide if the data should persist across sessions or can be temporary
(e.g., cache).
6.​ Performance – Consider efficiency; databases handle queries well but have higher
overhead for small key-value pairs.

3. Can We Use Multiple App Data Storage Types in a


Mobile Application?
Yes, different data types require different storage solutions.

Example 1: Social Media App

●​ SharedPreferences: Store user login credentials and app settings.


●​ Database: Store user posts, comments, and messages.
●​ Shared Storage: Save user-uploaded/downloaded media files (photos, videos).
●​ Cache: Temporarily store images for faster loading.

Example 2: Weather App

●​ SharedPreferences: Store user preferences (e.g., Celsius/Fahrenheit).


●​ Database: Store historical weather data.
●​ Cache: Store current weather data for offline access.

Using multiple storage types optimizes data management based on size, sensitivity, and
accessibility.
4. Differences Between Cache Data, SharedPreferences
Data, and Save Instance State Data
Aspect Cache Data SharedPreferences Data Save Instance State
Data

Purpose Temporary storage for Persistent storage for Temporary storage


quick access to small key-value pairs (e.g., for saving UI state
frequently used data. user preferences). during configuration
changes.

Persistence Non-persistent (can be Persistent (remains until Non-persistent (lost


cleared by the system or explicitly deleted). when the app
app). process is killed).

Storage Stored in the app's Stored in an XML file in Stored in a Bundle


Location cache directory the app's internal storage. object during activity
(internal/external lifecycle changes.
storage).

Use Case Caching images, API Storing user settings, app Saving UI state (e.g.,
responses, or temporary configurations, or simple text input, scroll
files for faster access. flags. position) during
rotations.

Accessibility Accessible only to the Accessible only to the app. Accessible only to the
app. app during the
activity lifecycle.

Lifetime Can be cleared by the Persists across app Persists only during
system when storage is restarts until explicitly the activity lifecycle
low or by the app. removed. (e.g., screen
rotation).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy