SlideShare a Scribd company logo
Android Share 
Preferences 
By: Ajay Panchal
Introduction 
▪ This is a sample android application development tutorial that show 
a how to save a android from data when ever immediately close the 
application in between registration. It is a so much treble full to refill 
all form data again. 
▪ So this tutorial show how you can put functionality in your android 
application, your application do not face this kind of problem while 
register in your android application. 
▪ It is an easy task to shave a form data while application is 
immediately close. We can call this functionality “Shared 
Preference”.
Shared Preference 
▪ The shared preference is a class that provide a storage area to store a 
small amount of temporary data you can save. 
▪ New Application with One Edit Text Control to take a user data into 
the form. 
▪ And we Are going to preserve value of this edit text control. Here we 
are user a predefined Class Called Shared Preference That Provided in 
to the android library.
New Application with one EditText 
Control
Code to set A text while restart A app 
▪ This code is written in on create method of class. 
▪ Code in onCreate() 
private EditText et; 
setContentView(R.layout.activity_main); 
et=(EditText) findViewById(R.id.editText1); 
SharedPreferences settings=getSharedPreferences("MYPREFS", 0); 
et.setText(settings.getString("tvalue", "")); 
▪ You can write private EditText et; in Global section of class if error.
Code For Application close 
▪ This code Preserve the current data that fill in the control. 
▪ The class shared preference class contain function for storing a 
intellectual data. 
▪ SharedPreference.Editor 
– android.content.SharedPreferences.Editor; 
– putString() is a method that provide a functionality to store data into the 
storage area, in this case SharedPreferences.
code 
▪ @Override 
▪ protected void onStop() { 
▪ // TODO Auto-generated method stub 
▪ super.onStop(); 
▪ SharedPreferences settings = getSharedPreferences("MYPREFS", 0); 
▪ SharedPreferences.Editor editor=settings.edit(); 
▪ editor.putString("tvalue", et.getText().toString()); 
▪ editor.commit(); 
▪ }
Thank You!

More Related Content

What's hot

Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
Jussi Pohjolainen
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
nationalmobileapps
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
Durai S
 
Tk2323 lecture 11 process and thread
Tk2323 lecture 11   process and threadTk2323 lecture 11   process and thread
Tk2323 lecture 11 process and thread
MengChun Lam
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
MaryadelMar85
 
Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | Edureka
Edureka!
 
Android intents
Android intentsAndroid intents
Android intents
Siva Ramakrishna kv
 
Android Services
Android ServicesAndroid Services
Android Services
Ahsanul Karim
 
Android resource
Android resourceAndroid resource
Android resource
Krazy Koder
 
Android animation
Android animationAndroid animation
Android animation
Krazy Koder
 
android activity
android activityandroid activity
android activity
Deepa Rani
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
Prem Kumar Badri
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
Tareq Hasan
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
Ahsanul Karim
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
Parinita03
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycle
Sokngim Sa
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android
DivyaKS12
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
Raghuveer Guthikonda
 

What's hot (20)

Android Location and Maps
Android Location and MapsAndroid Location and Maps
Android Location and Maps
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Tk2323 lecture 11 process and thread
Tk2323 lecture 11   process and threadTk2323 lecture 11   process and thread
Tk2323 lecture 11 process and thread
 
Database in Android
Database in AndroidDatabase in Android
Database in Android
 
Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | Edureka
 
Android intents
Android intentsAndroid intents
Android intents
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android resource
Android resourceAndroid resource
Android resource
 
Android animation
Android animationAndroid animation
Android animation
 
android activity
android activityandroid activity
android activity
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Day 4: Android: UI Widgets
Day 4: Android: UI WidgetsDay 4: Android: UI Widgets
Day 4: Android: UI Widgets
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycle
 
UI controls in Android
UI controls in Android UI controls in Android
UI controls in Android
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 

Viewers also liked

Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
nationalmobileapps
 
Android UI Patterns
Android UI PatternsAndroid UI Patterns
Android UI Patterns
Peter Pascale
 
planar wave guide
planar wave guide planar wave guide
planar wave guide
Zlatan Ahmadovic
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
Khaled Anaqwa
 
Android animation theory
Android animation theoryAndroid animation theory
Android animation theory
Siva Ramakrishna kv
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
Lars Vogel
 
Lecture Slides for Preferences and Menus [Android ]
Lecture Slides for Preferences and Menus [Android ]Lecture Slides for Preferences and Menus [Android ]
Lecture Slides for Preferences and Menus [Android ]
Nehil Jain
 
Hacking Mobile Apps
Hacking Mobile AppsHacking Mobile Apps
Hacking Mobile Apps
Sophos Benelux
 
Android ppt
Android pptAndroid ppt
Android ppt
Tarun Bamba
 
Disk management / hard drive partition management / create drive or partition...
Disk management / hard drive partition management / create drive or partition...Disk management / hard drive partition management / create drive or partition...
Disk management / hard drive partition management / create drive or partition...
Ajay Panchal
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
Sergi Martínez
 
Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCV
debayanin
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
Fernando Cejas
 
Android ppt
Android pptAndroid ppt
Android ppt
Prasadbharatiyudu
 
Image processing
Image processingImage processing
Image processing
Varun Raj
 
Image Processing
Image ProcessingImage Processing
Image Processing
Rolando
 

Viewers also liked (16)

Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 
Android UI Patterns
Android UI PatternsAndroid UI Patterns
Android UI Patterns
 
planar wave guide
planar wave guide planar wave guide
planar wave guide
 
Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)
 
Android animation theory
Android animation theoryAndroid animation theory
Android animation theory
 
Android design and Custom views
Android design and Custom views Android design and Custom views
Android design and Custom views
 
Lecture Slides for Preferences and Menus [Android ]
Lecture Slides for Preferences and Menus [Android ]Lecture Slides for Preferences and Menus [Android ]
Lecture Slides for Preferences and Menus [Android ]
 
Hacking Mobile Apps
Hacking Mobile AppsHacking Mobile Apps
Hacking Mobile Apps
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Disk management / hard drive partition management / create drive or partition...
Disk management / hard drive partition management / create drive or partition...Disk management / hard drive partition management / create drive or partition...
Disk management / hard drive partition management / create drive or partition...
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCV
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Image processing
Image processingImage processing
Image processing
 
Image Processing
Image ProcessingImage Processing
Image Processing
 

Similar to Android share preferences

DSC - Shared Preferences and Room
DSC - Shared Preferences and RoomDSC - Shared Preferences and Room
DSC - Shared Preferences and Room
Agustinus Theodorus
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
info_zybotech
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
bharatt7
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)
Kavya Barnadhya Hazarika
 
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
DicodingEvent
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
AbdullahMunir32
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
CITSimon
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
CITSimon
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
AbdullahMunir32
 
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
Padma shree. T
 
django
djangodjango
Code Quality Management iOS
Code Quality Management iOSCode Quality Management iOS
Code Quality Management iOS
Arpit Kulsreshtha
 
Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9
AHM Pervej Kabir
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!
Inexture Solutions
 
Presentation1
Presentation1Presentation1
Presentation1
Kshitiz Rimal
 
Iphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOSIphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOS
Kenny Nguyen
 
Android 102 - Flow, Layouts and other things
Android 102 - Flow, Layouts and other thingsAndroid 102 - Flow, Layouts and other things
Android 102 - Flow, Layouts and other things
Kai Koenig
 
Jmp108
Jmp108Jmp108
Jmp108
John Head
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
Deepak Garg
 

Similar to Android share preferences (20)

DSC - Shared Preferences and Room
DSC - Shared Preferences and RoomDSC - Shared Preferences and Room
DSC - Shared Preferences and Room
 
Notepad tutorial
Notepad tutorialNotepad tutorial
Notepad tutorial
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
 
Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)Android Development : (Android Studio, PHP, XML, MySQL)
Android Development : (Android Studio, PHP, XML, MySQL)
 
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
Mobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdfMobile Application Development-Lecture 13 & 14.pdf
Mobile Application Development-Lecture 13 & 14.pdf
 
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
 
django
djangodjango
django
 
Code Quality Management iOS
Code Quality Management iOSCode Quality Management iOS
Code Quality Management iOS
 
Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!
 
Presentation1
Presentation1Presentation1
Presentation1
 
Iphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOSIphone programming: Core Data Tutorial for iOS
Iphone programming: Core Data Tutorial for iOS
 
Android 102 - Flow, Layouts and other things
Android 102 - Flow, Layouts and other thingsAndroid 102 - Flow, Layouts and other things
Android 102 - Flow, Layouts and other things
 
Jmp108
Jmp108Jmp108
Jmp108
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
 

Recently uploaded

Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
ssuserad3af4
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
TaghreedAltamimi
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 

Recently uploaded (20)

Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Lecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptxLecture 2 - software testing SE 412.pptx
Lecture 2 - software testing SE 412.pptx
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 

Android share preferences

  • 1. Android Share Preferences By: Ajay Panchal
  • 2. Introduction ▪ This is a sample android application development tutorial that show a how to save a android from data when ever immediately close the application in between registration. It is a so much treble full to refill all form data again. ▪ So this tutorial show how you can put functionality in your android application, your application do not face this kind of problem while register in your android application. ▪ It is an easy task to shave a form data while application is immediately close. We can call this functionality “Shared Preference”.
  • 3. Shared Preference ▪ The shared preference is a class that provide a storage area to store a small amount of temporary data you can save. ▪ New Application with One Edit Text Control to take a user data into the form. ▪ And we Are going to preserve value of this edit text control. Here we are user a predefined Class Called Shared Preference That Provided in to the android library.
  • 4. New Application with one EditText Control
  • 5. Code to set A text while restart A app ▪ This code is written in on create method of class. ▪ Code in onCreate() private EditText et; setContentView(R.layout.activity_main); et=(EditText) findViewById(R.id.editText1); SharedPreferences settings=getSharedPreferences("MYPREFS", 0); et.setText(settings.getString("tvalue", "")); ▪ You can write private EditText et; in Global section of class if error.
  • 6. Code For Application close ▪ This code Preserve the current data that fill in the control. ▪ The class shared preference class contain function for storing a intellectual data. ▪ SharedPreference.Editor – android.content.SharedPreferences.Editor; – putString() is a method that provide a functionality to store data into the storage area, in this case SharedPreferences.
  • 7. code ▪ @Override ▪ protected void onStop() { ▪ // TODO Auto-generated method stub ▪ super.onStop(); ▪ SharedPreferences settings = getSharedPreferences("MYPREFS", 0); ▪ SharedPreferences.Editor editor=settings.edit(); ▪ editor.putString("tvalue", et.getText().toString()); ▪ editor.commit(); ▪ }