7

Actually i want to know how to store data from my app in the device so that i can review the store data when i run the application again..

means in simple terms i want to say that suppose i have text box where i write some information..now when i click the submit button, this information will be save,so that when i open the application the stored data should be appear in the text box..

In all terms i want to say that i just want to stored data in the way that we are using database for storing data..so please anyone suggest me how that can be done in android.

if possible show with an example

Regards Anshuman

AndroidDev
  • 4,521
  • 24
  • 78
  • 126

5 Answers5

9

If you have to store small amount of data, you can use SharedPreferences in Android.

If the data that you have to store is big/complex enough, try using SQLite database.

Still need help?

UPDATE: There's a tutorial that I wrote to demonstrate how to use SQLite database. check it out here. Although it copies existing database into device's memory, but other versions of it, which create database through code can also be devised from it.

A better tutorial is here : http://www.vogella.com/tutorials/AndroidSQLite/article.html

Aman Alam
  • 11,231
  • 7
  • 46
  • 81
4

1) If you want to store data in table format then you can use SQLite database in android

2) If you don't want to store data in table format then you can store in SharedPreference

more info about SharedPreference here and here

Community
  • 1
  • 1
Dharmendra
  • 33,296
  • 22
  • 86
  • 129
0

Android comes with a built in SQLite database that you can use. I advice you to go trough this notepad tutorial. It teaches the basics of using Android SDK including different states of the android application as well as how to use SQLite with Android.

OsQu
  • 1,048
  • 8
  • 12
0

For storing simple key = value pairs, you can use Properties.

For data storage as in a database, you can use sqlite on android.

Ozair Kafray
  • 13,351
  • 8
  • 59
  • 84
0

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.

Your data storage options are the following:

Shared Preferences

Store private primitive data in key-value pairs.

Internal Storage

Store private data on the device memory.

External Storage

Store public data on the shared external storage.

SQLite Databases

Store structured data in a private database.

Network Connection

Store data on the web with your own network server.

Data Storage

Faheem Kalsekar
  • 1,420
  • 3
  • 25
  • 31
  • I want the data to be accessible to the app even when it is upgraded. Which of the above solution should be used? Amount of data is small. For eg, to remember what levels have been cleared and what are remaining. – John Watson Jul 16 '12 at 06:43
  • 1
    SQLite Databases seems to be a good option. Database entries are not erased even when app is upgraded. Also you can store your data in a tabular and structured manned. – Faheem Kalsekar Jul 17 '12 at 05:31
  • what about shared preferences ? will they not persist through the upgrades ? – John Watson Jul 18 '12 at 10:52
  • 1
    shared preferences do persist across upgrades. My personal preference would be to use db. You can use Shared Pref. – Faheem Kalsekar Jul 31 '12 at 10:42