I change know to DocumentsDirectory I will check if helps in iOS 5
my code to manege with this download and remove from device is this:
chegaConexao = function()
local function networkListener( event )
if ( event.isError ) then
print( "erro de internet" )
else
print( "download xml" )
native.setActivityIndicator( false )
end
print ( "RESPONSE: " .. event.response )
end
local function testeConexao( event )
if ( event.isError ) then
local function onComplete( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
native.setActivityIndicator( false )
end
end
end
-- Show alert with five buttons
local alert = native.showAlert( "Error", "Network issue",
{ "OK" }, onComplete )
print ( "Network error - download failed" )
semInternet = true
else
network.download( "http://www.universopositivo.com.br/iphone/noticias.xml", "GET", networkListener, "noticias.xml", system.DocumentsDirectory )
semInternet = false
end
end
-- Access Google over SSL:
network.request( "https://google.com", "GET", testeConexao )
native.setActivityIndicator( true )
\_G.carregarXMLs = false
end
if \_G.carregarXMLs == true then
timer.performWithDelay( 500, chegaConexao, 1 )
end
--
--
-------------------------------------------------------
-------------------------------------------------------
-- Here I have put a update button and this is his function
atualiza = function()
local destDir2 = system.DocumentsDirectory -- where the file is stored
local results2, reason2 = os.remove( system.pathForFile( "noticias.xml", destDir2 ) )
if results2 then
print( "file removed" )
else
print( "file does not exist", reason2 )
end
local function networkListener2( event )
if ( event.isError ) then
local function onComplete2( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
native.setActivityIndicator( false )
end
end
end
-- Show alert with five buttons
local alert = native.showAlert( "Error", "Network issue",
{ "OK" }, onComplete2 )
print ( "Network error - download failed" )
else
print( "download xml" )
native.setActivityIndicator( false )
end
print ( "RESPONSE: " .. event.response )
end
local function testeConexao( event )
if ( event.isError ) then
local function onComplete( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
native.setActivityIndicator( false )
end
end
end
-- Show alert with five buttons
local alert = native.showAlert( "Error", "Network issue",
{ "OK" }, onComplete )
print ( "Network error - download failed" )
semInternet = true
else
network.download( "http://www.universopositivo.com.br/iphone/noticias.xml", "GET", networkListener2, "noticias.xml", system.DocumentsDirectory )
semInternet = false
end
end
-- Access Google over SSL:
network.request( "https://google.com", "GET", testeConexao )
native.setActivityIndicator( true )
end
-------------------------------------------------------
-------------------------------------------------------
-- and in the same .lua down there I have put a fill functions to manege the remove file function
function onSystemEvent( event )
if "applicationSuspend" == event.type or "applicationExit" == event.type then
local destDir = system.TemporaryDirectory -- where the file is stored
local results, reason = os.remove( system.pathForFile( "noticias.xml", destDir ) )
if results then
print( "file removed" )
else
print( "file does not exist", reason )
end
end
end
Runtime:addEventListener( "system", onSystemEvent )
function onSystemEvent2( event )
if "applicationResume" == event.type then
local function networkListener3( event )
if ( event.isError ) then
local function onComplete( event )
if "clicked" == event.action then
local i = event.index
if 1 == i then
native.setActivityIndicator( false )
end
end
end
-- Show alert with five buttons
local alert = native.showAlert( "Error", "Network issue",
{ "OK" }, onComplete )
print ( "Network error - download failed" )
else
print( "download xml" )
native.setActivityIndicator( false )
end
print ( "RESPONSE: " .. event.response )
end
network.download( "http://www.universopositivo.com.br/iphone/noticias.xml", "GET", networkListener3, "noticias.xml", system.DocumentsDirectory )
native.setActivityIndicator( true )
end
end
Runtime:addEventListener( "system", onSystemEvent2 )
So this is it
my code to manege with this XML download
EDIT: never mind guys… seems that after a while the newest version of XML was downloaded if I try to update or re-open my app
don’t know how to explain but… it’s working… for now [import]uid: 23063 topic_id: 16513 reply_id: 61721[/import]