Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

store long value in android database

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 .

like image 338
zafi005 Avatar asked Sep 25 '12 13:09

zafi005


People also ask

How to store data in database in Android?

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.

Does SQLite support long?

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.

Where does SQLite store data in Android?

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.

What is the difference between int and Integer in SQLite?

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.


2 Answers

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

like image 152
keyser Avatar answered Oct 06 '22 07:10

keyser


You can define a column with Integer datatype. For more info go through this link

like image 3
Aswin Avatar answered Oct 06 '22 07:10

Aswin