Reputation: 2667
I want to store a timevalue in an SQLite database in Android. My time value is in EditText, and when I click the save button I would like the time value to be stored in the database. And also I want to review the already-stored value in the database.
Upvotes: 8
Views: 19128
Reputation: 3106
Sqlite + timestamp = Date and time functions
Sqlite + timestamp + android = Timestamp Class
Other options
Upvotes: 3
Reputation: 3066
SQLite doesn't have a specific datatype for storing times, and leaves it up to you whether you want to store them as text, integers, or floating-point values, so you can establish whatever convention works best for you.
For your application where you want the time to be editable by the user I'd suggest looking into the DatePicker and TimePicker widgets, so that you don't have to worry about parsing and formatting the time as text, and then the Java Calendar class for converting the data from those into a simple value that you can put in the database (I'd suggest using the getTimeInMillis() method to convert it into a integer).
Upvotes: 6