SlideShare una empresa de Scribd logo
1 de 8
Descargar para leer sin conexión
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!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Android contentprovider
Android contentproviderAndroid contentprovider
Android contentprovider
 
android layouts
android layoutsandroid layouts
android layouts
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Intents in Android
Intents in AndroidIntents in Android
Intents in Android
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android User Interface
Android User InterfaceAndroid User Interface
Android User Interface
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Action Bar in Android
Action Bar in AndroidAction Bar in Android
Action Bar in Android
 
Data Persistence in Android with Room Library
Data Persistence in Android with Room LibraryData Persistence in Android with Room Library
Data Persistence in Android with Room Library
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Broadcast Receiver
Broadcast ReceiverBroadcast Receiver
Broadcast Receiver
 
Share preference
Share preferenceShare preference
Share preference
 
Servlets
ServletsServlets
Servlets
 

Destacado

Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Android Training (Storing & Shared Preferences)
Android Training (Storing & Shared Preferences)Khaled Anaqwa
 
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
 
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
 
Image Processing with OpenCV
Image Processing with OpenCVImage Processing with OpenCV
Image Processing with OpenCVdebayanin
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsFernando Cejas
 
Image processing
Image processingImage processing
Image processingVarun Raj
 
Image Processing
Image ProcessingImage Processing
Image ProcessingRolando
 

Destacado (15)

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...
 
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 a Android share preferences

DSC - Shared Preferences and Room
DSC - Shared Preferences and RoomDSC - Shared Preferences and Room
DSC - Shared Preferences and RoomAgustinus Theodorus
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptbharatt7
 
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.pdfAbdullahMunir32
 
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.pdfAbdullahMunir32
 
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
 
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-9AHM 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
 
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 iOSKenny 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 thingsKai Koenig
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-pythonDeepak Garg
 

Similar a 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
 

Último

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotEdgard Alejos
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainAbdul Ahad
 

Último (20)

Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform Copilot
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software Domain
 

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(); ▪ }