How do I store long values in Android SQLite database ? I am trying to store the time(milliseconds) values which comes in long type format .
Create a database using an SQL helper"DROP TABLE IF EXISTS " + FeedEntry. TABLE_NAME; Just like files that you save on the device's internal storage, Android stores your database in your app's private folder. Your data is secure, because by default this area is not accessible to other apps or the user.
SQLite does not support built-in date and time storage classes. However, you can use the TEXT, INT, or REAL to store date and time values.
The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.
However, the dynamic typing in SQLite allows it to do things which are not possible in traditional rigidly typed databases. So in MS Sql Server (for example), an "int" == "integer" == 4 bytes/32 bits. In contrast, a SqlLite "integer" can hold whatever you put into it: from a 1-byte char to an 8-byte long long.
An INTEGER column will handle long values.
From the SQLite site:
INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
Datatypes In SQLite Version 3
You can define a column with Integer datatype. For more info go through this link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With