Your SlideShare is downloading. ×
0
SharedPreferences Tutorial
SharedPreferences Tutorial
SharedPreferences Tutorial
SharedPreferences Tutorial
SharedPreferences Tutorial
SharedPreferences Tutorial
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

SharedPreferences Tutorial

16,068

Published on

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
16,068
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
279
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Android Application Development
    Shared Preferences for Persistence
    Ahsanul Karim
    ahsanul.karim@sentinelbd.com
    Sentinel Solutions Ltd.
    http://www.sentinelbd.com
  • 2. Shared Preferences for Persistence
    Android applications can store data in application preferences.
    In this tutorial, you learn how to store persistent application data with shared preferences.
    Preferences in Android are used to keep track of application and user preferences.
    In any application, there are default preferences that can accessed through the
    PreferenceManagerinstance and its related method 
    getDefaultSharedPreferences(Context)
    With the SharedPreference instance one can retrieve the int value of the any preference
    with the getInt(String key, intdefVal).
    In our case, we can modify the SharedPreference instance in our case using the 
    edit() and use the putInt(String key, intnewVal) 
  • 3. Shared Preferences for Persistence
    We see an example of this:
    We create a project:
    We also create a layout
  • 4. Shared Preferences for Persistence
    Here is our Activity
  • 5. Shared Preferences for Persistence
    We read and write now:
  • 6. Shared Preferences for Persistence
    Now we run the app:
    For testing we set a value
    Exit application
    Launch the app again
    Retrieve the value

×