sqlite - Storing float numbers as strings in android database -


so have app put arbitrary strings in database , later extract them this:

cursor dbresult = mydatabase.query(false, constant.database_notes_table_name,              new string[] {"mystuff"}, where, null, null, null, null, null); dbresult.getstring(0); 

this works fine in cases except when string looks float number, example "221.123123123". after saving database can extract database computer , inside db-viewer, , saved number correct. however, when using cursor.getstring() string "221.123" returned. cant life of me understand how can prevent this. guess cursor.getdouble() on every single string see if gives better result, feels sooo ugly , inefficient. suggestions?

cheers,

edit: made small test program. program prints "result: 123.123", when print "result: 123.123123123"

sqlitedatabase database = openorcreatedatabase("databas", context.mode_private, null); database.execsql("create table if not exists tabell (nyckel string primary key);");  contentvalues value = new contentvalues(); value.put("nyckel", "123.123123123"); database.insert("tabell", null, value);  cursor result = database.query("tabell", new string[]{"nyckel"}, null, null, null, null, null); result.movetofirst(); log.d("tag","result: " + result.getstring(0)); 

well, solved own question. problem arises me using "string" when creating table, instead of "text" (which seems sqlite equivalence of varchar). because sqlite accepts type, can read under http://www.sqlite.org/datatype3.html "2.1 determination of column affinity":

"#otherwise, affinity numeric."

so type isnt recognized numeric... "string"-type numeric. gah!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -