- Previous thread: android-developers - Overlays Erased on Screen Orientation Change
- Next thread: android-developers - twitter and facebook intent : suggestion for the community
- Threads sorted by date: android-developers 201004
Has anyone been able to get Long Integers to work with a SQLite DB on
Android?
In particular, I am noticing some odd behavior with Webkit's Cache
Database. The "expires" column is always 0. After doing some testing,
I realized that SQLite will accept a value in the "expires" column up
to (2^31 - 1). Anything higher than this, and the value is always 0.
The cache database uses Date.getTime() to populate this field. Since
this is a long, the value is always 0.
Is this a bug in the Cache Database or the SQLite implementation?
Jeff
Android?
In particular, I am noticing some odd behavior with Webkit's Cache
Database. The "expires" column is always 0. After doing some testing,
I realized that SQLite will accept a value in the "expires" column up
to (2^31 - 1). Anything higher than this, and the value is always 0.
The cache database uses Date.getTime() to populate this field. Since
this is a long, the value is always 0.
Is this a bug in the Cache Database or the SQLite implementation?
Jeff
Here is a list of data types that are allowed in SQLite 3:
http://www.sqlite.org/datatype3.html
Note that there is no official "long" data type. It would be classified as
INTEGER or REAL. For actual "long" data types that don't seem to be stored
well in SQLite you might do better to store as TEXT and do a conversion
outside of SQLite.
I am by no means a database expert though, perhaps someone with more SQLite
experience will chime in with a better explanation.
Justin
Has anyone been able to get Long Integers to work with a SQLite DB on
Android?
In particular, I am noticing some odd behavior with Webkit's Cache
Database. The "expires" column is always 0. After doing some testing,
I realized that SQLite will accept a value in the "expires" column up
to (2^31 - 1). Anything higher than this, and the value is always 0.
The cache database uses Date.getTime() to populate this field. Since
this is a long, the value is always 0.
Is this a bug in the Cache Database or the SQLite implementation?
Jeff
http://www.sqlite.org/datatype3.html
Note that there is no official "long" data type. It would be classified as
INTEGER or REAL. For actual "long" data types that don't seem to be stored
well in SQLite you might do better to store as TEXT and do a conversion
outside of SQLite.
I am by no means a database expert though, perhaps someone with more SQLite
experience will chime in with a better explanation.
Justin
Has anyone been able to get Long Integers to work with a SQLite DB on
Android?
In particular, I am noticing some odd behavior with Webkit's Cache
Database. The "expires" column is always 0. After doing some testing,
I realized that SQLite will accept a value in the "expires" column up
to (2^31 - 1). Anything higher than this, and the value is always 0.
The cache database uses Date.getTime() to populate this field. Since
this is a long, the value is always 0.
Is this a bug in the Cache Database or the SQLite implementation?
Jeff
I spent 2 days trying to figure this out, and wouldn't you know it...2
minutes after posting to the group, I think I have figured out what I was
doing wrong.
In order to check my work, I was exporting the database to my local computer
and opening it with SQLite Administrator. The values were appearing as 0
because the "affinity" of this column in the database was set as INTEGER. So
it while is appeared that these values were getting stored as 0, in
actuality they were just getting displayed as 0 in SQLite Administrator.
The true value of these fields are indeed getting stored properly. I just
had to CAST(expires as NUMERIC) in order to view them.
Sorry for the false alarm.
The true value of these fields are indeed getting stored properly. I just had to CAST(expires as NUMERIC) in order to view them.
minutes after posting to the group, I think I have figured out what I was
doing wrong.
In order to check my work, I was exporting the database to my local computer
and opening it with SQLite Administrator. The values were appearing as 0
because the "affinity" of this column in the database was set as INTEGER. So
it while is appeared that these values were getting stored as 0, in
actuality they were just getting displayed as 0 in SQLite Administrator.
The true value of these fields are indeed getting stored properly. I just
had to CAST(expires as NUMERIC) in order to view them.
Sorry for the false alarm.
The true value of these fields are indeed getting stored properly. I just had to CAST(expires as NUMERIC) in order to view them.
Related Threads
- mongodb-user - How to remove null values from arrays ? - mongodb-user
- rules-users - Configuring Persistance to JBoss - jboss-rules-users
- subquery multiple rows - mysql-general
- installing edge on jruby - buildr-users
- Question about parsing URL in Ruby - ruby-talk
- twaking the $VERSION of the make dist targets - gnu-automake
- UPDATE: security/libssh2 - openbsd-ports
- CentOS - oVirt - Setting up a web GUI for VM Management - centos-general
- Change fields sent in Whine emails - support-bugzilla
- Abstract attributes - python-list