انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Data Persistence : shared preferences

الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 3
أستاذ المادة علي كاظم خضير البيرماني       07/01/2017 19:44:58
WHAT YOU WILL LEARN IN THIS LECTURE

? How to save simple data using the SharedPreferences object

? Enabling users to modify preferences using a PreferenceActivity class

? How to write and read files in internal and external storage

? Creating and using a SQLite database


In this lecure, you will learn how to persist data in your Android applications. Persisting data
is an important topic in application development, as users typically expect to reuse data in the
future. For Android, there are primarily three basic ways of persisting data:

? A lightweight mechanism known as shared preferences to save small chunks of data

? Traditional file systems

? A relational database management system through the support of SQLite databases The techniques discussed in this chapter enable applications to create and access their own private data. In the next chapter you’ll learn how you can share data across applications.

SAVING AND LOADING USER PREFERENCES
Android provides the SharedPreferences object to help you save simple application data.
For example, your application may have an option that enables users to specify the font size of the text displayed in your application. In this case, your application needs to remember the size set by the user so that the next time he or she uses the application again, it can set the size appropriately. In order to do so, you have several options. You can save the data to a fi le, but you have to perform some fi le management routines, such as writing the data to

المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .