Android BASICS Persistent Storage Options. Data storage in Android.

Useful Video : https://youtu.be/oOR84vMwoac


Options we have in Android for Persistent Data Storage :






--------------------------------------------------------------------------------------------------------------

SHARED PREFERENCES :


We use getSharedpreferences() to get the APP LEVEL PREFERENCE.
We use getpreferences() to get the ACTIVITY LEVEL PREFERENCE.


Useful Video : https://youtu.be/8VVZK8TzC64

1] It is the easiest way to store data , Data is Stored in XML files.

2] Stores Data in INTERNAL STORAGE and keeps it UN-ENCRYPTED

3] Data is Stored as  A KEY-VALUE pair.

4] Key is Always in String , While the Value can be in String,Int,Long,Boolean,Float.

5] Shared preferences are of two levels - Activity Level & App Level

Preferences created at Activity Level can only be Acessed by the same Activity whihc created it.

App level Preferences can be Acessed throughout the App

6] There are 2 ways to work with Preferences , 

i] Using Preference Activity (No java code required)

ii]  Using Java Code

7] Never Store Sensetive DATA in Shared Preferences.

8] DATA GET DELETED IF APP IS UNINSTALLED


------------------------------------------------------------------------------------


INTERNAL & EXTERNAL STORAGE :

 An input stream is used to read data from the source. And, an output stream is used to write data to the destination.

1] Internal storage files are private and cannot be accessed by other apps/users.
2] External Storage files can be kept as Private & Public .
3] Android framework decides which part of memory to keep as Internal and External storage.
4] Private files are excrypted.















-----------------------------------------------------------------------------------

Create APP level Shared preference :



Create Activity level Shared preference.


Writing & Reading, Deleting  files from Internal Storage :

Writing & Reading, Deleting  files from External Storage :


















Comments

Popular posts from this blog

React Js + React-Redux (part-2)

React Js + CSS Styling + React Router (part-1)

ViteJS (Module Bundlers, Build Tools)