write string 0'-1" into sqlite android database -


i cant seem right asking overlooking in code. here's i've got in code:

newleasedata = "insert " + enterlogln + " (date, "             + "stocktank1ft, stocktank1inch, stocktank2ft, stocktank2inch, "             + "stocktank3ft, stocktank3inch, stocktank4ft, stocktank4inch, "             + "change1, change2, change3, change4) values "              + "(" + today + ", '" + valuet1ft + "', '" + valuet1inch + "', '" + valuet2ft              + "', '" + valuet2inch + "', '" + valuet3ft + "', '" + valuet3inch              + "', '" + valuet4ft + "', '" + valuet4inch + "', " + diftotalt1              + ", " + diftotalt2 + ", " + diftotalt3 + ", " + diftotalt4 + ")"; 

everything works until strings: diftotalt1, diftotalt2, diftotalt3 , diftotalt4. each string set like: 0'-1" , 0'-2" , 0'-3" or 0'-4" , when try exec command:

mydatabase.execsql(enterlogdataoilactivity.newleasedata); 

my app crashes logcat error:

06-05 04:36:23.824: e/androidruntime(1127): android.database.sqlite.sqliteexception: near "'-1", 0'": syntax error: insert (date, stocktank1ft, stocktank1inch, stocktank2ft, stocktank2inch, stocktank3ft, stocktank3inch, stocktank4ft, stocktank4inch, change1, change2, change3, change4) values ('05_05_12', '0', '1', '0', '2', '0', '3', '0', '4', 0'-1", 0'-2", 0'-3", 0'-4")

thanks know has got simple. have tried inclosing each diftotalt1 string single quote not work either (ie diftotalt1 = "'" + diftotalt1 + "'";)

this string used create table in sqlite:

newleasetable = "create table '" + leasename + "' (_id integer primary key autoincrement,"             + " date text, stocktank1ft numeric, stocktank1inch numeric,"             + " stocktank2ft numeric, stocktank2inch numeric, stocktank3ft numeric,"             + " stocktank3inch numeric, stocktank4ft numeric, stocktank4inch numeric,"             + " change1 text, change2 text, change3 text, change4 text, user text);"; 

you have escape quotes backslashes, i.e.

diftotal = "0\\\'-1\\\""; 

this results in diftotal being "0\'-1\"" when use insert mysql.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -