Previous | Home | Next |
You can store data in Android .Android provides several options to save persistent application data that is depended your need. if you do not want to share the data other application that means data should be private to your application.
There are several option for the data store :
- 1. Preferences : Preferences is a lightweight mechanism to store and retrieve primitive data types eg. booleans, floats, ints, longs, and strings etc. in key-value pairs. SharedPreferences class is used for this purpose. if you need multiple preferences files identified by name, which you specify with the first parameter then getSharedPreferences() is used and getPreferences() is used this if you need only one preferences file for your Activity.You don't supply a name.
- Internal Storage : Internal storage data store is used when you want to store data in files on your mobile phone.By default, files saved to the internal storage are private to your application.
- External Storage : External storage data store is used when you want to store public in a removable storage or external storage medium.
- SQLite Databases : Android Api supports SQLite databases. All databases, SQLite and others, are Store structured data in a private database. The to create a new SQLite database that class extends SQLiteOpenHelper class and override the onCreate() method. when you want to use SQLite data storage, first create table in data base.
- Network Connection : Network connection is used to store data on own network server .You can also use the Internet to store and receive data, whether it's an SQLite database, or just a simple textfile.
SharedPreferences setting = getSharedPreferences(My_Name, 0);
.SharedPreferences.Editor editor = settings.edit();
editor.commit();
Previous | Home | Next |