the first one was an example my whole part for sqlite script is:
[lua]require “sqlite3”
local path_db = system.pathForFile(“data.db”, system.DocumentsDirectory)
db = sqlite3.open( path_db )
–Handle the applicationExit event to close the db
local function onSystemEvent( event )
if( event.type == “applicationExit” ) then
if db:isopen() then
db:close()
end
end
end
–Setup the table if it doesn’t exist
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content, content2);]]
db:exec( tablesetup )
local function favoriten_plus (event)
–Add rows with a auto index in ‘id’. You don’t need to specify a set of values because we’re populating all of them
local testvalue = {}
testvalue[1] = data_eintrag
testvalue[2] = ‘Gastro’
local tablefill =[[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[2]…[[’);]]
db:exec( tablefill )
–for row in db:nrows(“SELECT * FROM test”) do
–print (row.content)
–end
end
local function fav_touch ( event )
if event.phase==“ended” then
transition.to(detail_fav_aktiv, {time=1, x=0, transition=easing.outExpo })
timer.performWithDelay(50, favoriten_plus)
–print (“INAKTIV”)
end
–local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);]]
return true
end
local function fav_aktiv_touch ( event )
if event.phase ==“ended” then
local delete_sql = [[DELETE FROM test WHERE content=’]]… data_eintrag …[[’;]]
db:exec( delete_sql )
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);]]
db:exec( tablesetup )
print (“AKTIV”)
transition.to(detail_fav_aktiv, {delay=100,time=1, x=display.contentWidth+600, transition=easing.outExpo })
–transition.to(detail_fav_aktiv, {time=100, alpha=0, transition=easing.outExpo })
end
return true
end[/lua]
in one file and in another file to generate a tableview with the favorites which are generated before it is this script
[lua]local path_db = system.pathForFile(“data.db”, system.DocumentsDirectory)
db = sqlite3.open( path_db )
–Handle the applicationExit event to close the db
local function onSystemEvent( event )
if( event.type == “applicationExit” ) then
if db:isopen() then
db:close()
end
end
end
–Setup the table if it doesn’t exist
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content, content2);]]
db:exec( tablesetup )
local function favoriten_plus (event)
–Add rows with a auto index in ‘id’. You don’t need to specify a set of values because we’re populating all of them
local testvalue = {}
testvalue[1] = data_eintrag
testvalue[2] = ‘Gastro’
local tablefill =[[INSERT INTO test VALUES (NULL, ‘]]…testvalue[1]…[[’,’]]…testvalue[2]…[[’);]]
db:exec( tablefill )
–for row in db:nrows(“SELECT * FROM test”) do
–print (row.content)
–end
end
local function fav_touch ( event )
if event.phase==“ended” then
transition.to(detail_fav_aktiv, {time=1, x=0, transition=easing.outExpo })
timer.performWithDelay(50, favoriten_plus)
–print (“INAKTIV”)
end
–local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);]]
return true
end
local function fav_aktiv_touch ( event )
if event.phase ==“ended” then
local delete_sql = [[DELETE FROM test WHERE content=’]]… data_eintrag …[[’;]]
db:exec( delete_sql )
local tablesetup = [[CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, content);]]
db:exec( tablesetup )
print (“AKTIV”)
transition.to(detail_fav_aktiv, {delay=100,time=1, x=display.contentWidth+600, transition=easing.outExpo })
–transition.to(detail_fav_aktiv, {time=100, alpha=0, transition=easing.outExpo })
end
return true
end
local function fav_bestuecken ( event )
transition.to(detailScreen, {time=400, x=display.contentWidth, transition=easing.outExpo })
transition.to(myList, {time=400, x=0, transition=easing.outExpo })
transition.to(detail_zurueck_btn, {time=1, x=oben_links_leer.x, transition=easing.outExpo })
transition.to(detail_karte_oben_rechts, {time=1, x=oben_rechts_leer.x, transition=easing.outExpo })
delta, velocity = 0, 0
if ( section == 3 ) then
–print (“ERREICHT”)
else
local function networkListener ( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
jSon_result = dkjson.decode(event.response)
entrycount = jSon_result.entrycount
for k,v in pairs(jSon_result) do
–print (k,v)
local b
for b=1, 999 do
if (k== “entry_”…b) then
for row in db:nrows(“SELECT * FROM test”) do
–print ( row.content )
if ( v.name~=nil and v.street~=nil and v.zip ~= nil and v.city ~= nil and v.thumb ~= nil and row.content == v.id ) then
array[w]={}
array[w].id=v.id
array[w].name=v.name
array[w].street=v.street
array[w].zip=v.zip
array[w].city=v.city
array[w].thumb=v.thumb
array[w].number=w
local path = system.pathForFile( “list_fav”… w …".png", system.DocumentsDirectory )
myFile = io.open( path, “w+b” )
– Request remote file and save data to local file
http.request{
url = “http:…”… v.thumb,
sink = ltn12.sink.file(myFile),
}
timer.performWithDelay(500, fav_bestuecken )
data[w] = {}
data[w].id=array[w].id
data[w].title = array[w].name
data[w].subtitle = array[w].street
data[w].number = array[w].number
table.insert(data, data[i])
w = w+1
else
timer.performWithDelay(500, fav_bestuecken )
end
end
end
end
end
end
if ( section == 3 and request_phase == true ) then
–print (“GDS”)
timer.performWithDelay ( 1000 , liste_bestuecken )
request_phase = false
end
end
section = section + 1
responseJSon = network.request( “http:…function=” … mime.b64(field) … “§ion=” … mime.b64(section), “GET”, networkListener )
–print (section)
end
end[/lua]
and this works well on corona simulator but not on iPhone [import]uid: 149464 topic_id: 28840 reply_id: 116441[/import]