0
在corona中將數據從本地文本字段保存到sqlite數據庫非常困難。如何將數據從nativeTextField保存到corona中的sqlite數據庫中
這裏有一些相關的代碼:
function printrecord()
for row in db:nrows("SELECT * FROM test") do
t = display.newText(row.pname .. " " .. row.age .. " " .. row.desc, 20, 30 * row.id, null, 16)
t:setTextColor(255,255,255)
end
end
newData = native.newTextField (20, _H - 90, 280, 30)
newData.inputType = "text"
saveData = function (event)
textString = newData.text
db:exec([[ INSERT INTO test VALUES (NULL, textString, 30, "unknown")]])
t:removeSelf()
t = nil
printrecord()
end
savebutton = widget.newButton {
default = "buttonGreen.png",
over = "buttonGreenOver.png",
label = "Save",
embose = true,
onRelease = saveData
}
當我嘗試從db:exec([[ INSERT INTO test VALUES (NULL, textString, 30, "unknown")]])
的textString
改變,如「這是一個字符串」它似乎做工精細字符串,誰能幫助?
很久以前就已經想到了這一點,感謝您的幫助。 – philip