-1

My Course class has 4 fields :

String name;
String startHour
String startEnd
String day

I need to save objects of this class and load it every time the user starts the application with the saved objects. In addition, the user can add or delete objects (that is , add/remove courses).

What's the best way to do it ? SharedPrefernces ? JSon ?

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Sharon182
  • 100
  • 1
  • 3
  • 10

1 Answers1

1

Since user can add/delete/modify, using a database would be your best option, SQLite is what you want.

http://www.vogella.com/tutorials/AndroidSQLite/article.html

ashishduh
  • 6,629
  • 3
  • 30
  • 35
  • What will be the primary key ? Two courses can have the same name but different times. SQLite is not object oriented, as i know... – Sharon182 Jul 31 '14 at 15:47
  • If i'll attach every course object an id , how will i know to assign an id that hasn't been assigned already ? – Sharon182 Jul 31 '14 at 15:50
  • The primary key will just be an auto-incremented integer. http://sqlite.org/autoinc.html – ashishduh Jul 31 '14 at 15:56