Pr.Pg Next Pg

Storage Options Tutorials

  • Android provides several options for you to save persistent application data.

  • The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires.

  • The four major types of storage options are Shared Preferences, Internal Storage, External Storage, SQLite Databases and Network Connection.

Shared Preferences

  • If you need to store simple data items for your apps, the most straightforward approach is to use Shared Preferences.

  • This is possibly the easiest data management option to implement, but itís only suitable for primitive type items such as numbers and text.

  • Using Shared Preferences, you model your data items as key value pairs.

Internal Storage

  • You can store data items to the internal storage on your usersí devices.

  • The advantage to this is that it does not rely on any external media, but the disadvantage is that some devices have extremely limited amounts of storage space available.

  • Storing to internal memory essentially means saving data files within the internal device directory structure.

External Storage

  • Many Android users are dependent on external media storage such as SD cards due to insufficient internal storage.

  • SD cards offer your apps an increased amount of storage space, but they impose additional considerations.

  • For example, you cannot assume that a user will have an SD card or other external media resource.

  • For this reason your programming code needs to carry out checks before storing data in this way. 

Databases

  • If your app uses more complex data items, you can create a SQLite database to store them using the relational model.

  • When you create a SQLite database for your app, you can access it from any point within your Java code, and it will not be accessible from anywhere else.

  • There are many advantages to using a database, such as the ability to store and execute structured queries.

Network Connections

  • Store data on the web with your own network server.

  • Android provides a way for you to expose even your private data to other applications ó with a content provider.

  • A content provider is an optional component that exposes read/write access to your application data, subject to whatever restrictions you want to impose. 

 

Pr.Pg border                                              Next Pg