Storing data Android Flashcards

1
Q

Storage Options

A

Shared Preferences—Private primitive data in key-value pairs
Internal Storage—Private data on device memory
External Storage—Public data on device or external storage
SQLite Databases—Structured data in a private database
Content Providers—Store privately and make available publicly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

External Storage

A

On device or SD card
Not always available, can be removed
World-readable, so any app can read
On uninstall, system does not remove files private to app

BEST WHEN
don’t require access restrictions and for

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Internal Storage

A

Uses private directories just for your app
App always has permission to read/write
On app uninstall, system removes all app’s files from internal storage

BEST WHEN
you want to be sure that neither the user nor other apps can access your files

Permanent storage directory—getFilesDir()
Temporary storage directory—getCacheDir()

Usage:
File file = new File(
context.getFilesDir(), filename);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Content Provider?

A

A ContentProvider is a component that interacts with a repository(which could by a database, a file system, or the cloud). The app doesn’t need to know where or how the data is stored, formatted, or accessed.

Store data or develop backend independently from UI
Securely make data available to other apps
Manage access permissions to app data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a Content Resolver?

A

A content resolver is a component that your app uses to send requests to a content provider
Requests consist of a content URI and an SQL-like query
The ContentResolver object provides query(), insert(), update(), and delete() methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly