Skip to main content

Storing Data

  • Chapter
  • First Online:
Android Quick APIs Reference
  • 2067 Accesses

Abstract

The Android framework provides several options to store application data. There is no single best storage option, as the options depend on the application and the use cases. This chapter briefly goes through each of the storage options offered by the Android framework, such as simple files, shared preferences, and the relational databases. Later in this chapter, we will explore Android Backup Services as a mechanism to back up and restore application data to the cloud in order make it persist between device upgrades and device resets.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 37.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    http://developer.android.com/reference/android/content/Context.html# openFileOutput(java.lang.String,int) .

  2. 2.

    http://developer.android.com/reference/android/content/Context.html# openFileInput(java.lang.String) .

  3. 3.

    http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState() .

  4. 4.

    http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory() .

  5. 5.

    http://developer.android.com/reference/android/content/Context.html# getExternalFilesDir(java.lang.String) .

  6. 6.

    http://developer.android.com/reference/android/content/Context.html# getExternalFilesDir(java.lang.String) .

  7. 7.

    http://developer.android.com/reference/android/os/Environment.html# getExternalStoragePublicDirectory(java.lang.String) .

  8. 8.

    http://developer.android.com/reference/android/content/Context.html# getCacheDir() .

  9. 9.

    http://developer.android.com/reference/android/content/Context.html# getExternalCacheDir() .

  10. 10.

    http://developer.android.com/reference/android/util/JsonWriter.html .

  11. 11.

    http://developer.android.com/reference/android/util/JsonReader.html .

  12. 12.

    http://developer.android.com/reference/android/content/Shared Preferences.html .

  13. 13.

    http://developer.android.com/reference/android/app/Activity.html#get Preferences(int) .

  14. 14.

    http://developer.android.com/reference/android/content/ContextWrapper.html#getSharedPreferences(java.lang.String, int) .

  15. 15.

    http://developer.android.com/reference/android/content/Shared Preferences.Editor.html .

  16. 16.

    http://developer.android.com/reference/android/content/Shared Preferences.html#edit() .

  17. 17.

    http://developer.android.com/reference/android/content/Shared Preferences.Editor.html#commit() .

  18. 18.

    http://developer.android.com/reference/android/content/Shared Preferences.html#contains(java.lang.String) .

  19. 19.

    http://developer.android.com/reference/android/content/Shared Preferences.html#registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener) .

  20. 20.

    http://developer.android.com/reference/android/preference/Preference Fragment.html .

  21. 21.

    http://developer.android.com/reference/android/preference/Preference Screen.html .

  22. 22.

    http://developer.android.com/reference/android/preference/CheckBox Preference.html .

  23. 23.

    http://developer.android.com/reference/android/preference/List Preference.html .

  24. 24.

    http://developer.android.com/reference/android/preference/EditText Preference.html .

  25. 25.

    http://developer.android.com/reference/android/database/sqlite/SQLite OpenHelper.html .

  26. 26.

    http://developer.android.com/reference/android/database/sqlite/SQLite OpenHelper.html#onCreate(android.database.sqlite.SQLiteDatabase) .

  27. 27.

    http://developer.android.com/reference/android/database/sqlite/SQLite OpenHelper.html#onUpgrade(android.database.sqlite.SQLiteDatabase, int, int) .

  28. 28.

    www.sqlite.org/lang_createtable.html .

  29. 29.

    www.sqlite.org/lang_altertable.html .

  30. 30.

    http://developer.android.com/reference/android/database/sqlite/SQLite OpenHelper.html#getWritableDatabase() .

  31. 31.

    www.sqlite.org/lang_insert.html .

  32. 32.

    http://developer.android.com/reference/android/database/sqlite/SQLite Database.html#insert(java.lang.String, java.lang.String, android. content.ContentValues) .

  33. 33.

    www.sqlite.org/lang_update.html .

  34. 34.

    http://developer.android.com/reference/android/database/sqlite/SQLite Database.html#update(java.lang.String, android.content.ContentValues, java.lang.String, java.lang.String[]) .

  35. 35.

    www.sqlite.org/lang_select.html#whereclause .

  36. 36.

    http://developer.android.com/reference/android/database/sqlite/SQLite OpenHelper.html#getReadableDatabase() .

  37. 37.

    http://developer.android.com/reference/android/database/sqlite/SQLite Database.html#query(java.lang.String, java.lang.String[], java.lang. String, java.lang.String[], java.lang.String, java.lang.String, java.lang.String, java.lang.String) .

  38. 38.

    http://developer.android.com/reference/android/database/Cursor.html .

  39. 39.

    www.sqlite.org/lang_select.html#resultset .

  40. 40.

    www.sqlite.org/lang_select.html#orderby .

  41. 41.

    www.sqlite.org/lang_select.html#limitoffset .

  42. 42.

    http://developer.android.com/reference/android/database/sqlite/SQLite Database.html#delete(java.lang.String, java.lang.String, java.lang. String[]) .

  43. 43.

    http://developer.android.com/reference/android/content/Context.html# deleteDatabase(java.lang.String) .

  44. 44.

    http://developer.android.com/guide/topics/data/backup.html .

  45. 45.

    http://developer.android.com/reference/android/app/backup/BackupAgent.html .

  46. 46.

    http://developer.android.com/reference/android/app/backup/BackupAgent Helper.html .

  47. 47.

    http://developer.android.com/reference/android/app/backup/FileBackup Helper.html .

  48. 48.

    http://developer.android.com/reference/android/app/backup/Shared PreferencesBackupHelper.html .

  49. 49.

    http://developer.android.com/guide/topics/manifest/application-element.html#agent .

  50. 50.

    http://developer.android.com/reference/android/app/backup/Backup Manager.html#dataChanged() .

  51. 51.

    http://developer.android.com/tools/help/bmgr.html .

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2015 Onur Cinar

About this chapter

Cite this chapter

Cinar, O. (2015). Storing Data. In: Android Quick APIs Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0523-5_7

Download citation

Publish with us

Policies and ethics