Bacground Image from Gallery

Hi, 
I am creating an app and i want allow the user to cho se the backround of the application but I am a newbie and i don’t any idea about what should i have to do
I created a button that open the gallery, but now i don’t know what I have to do in order to get the selected file and save it in some way in order thet the selected image could be used as background in the further launches of the application

Sorry for the bad english 

here the code of the button

[lua]function gallery:touch(event)

if event.phase == “began” then
if media.hasSource( media.PhotoLibrary ) then
media.selectPhoto( { mediaSource=media.PhotoLibrary, listener=onComplete, destination = path } )
else
native.showAlert( “Corona”, “This device does not have a photo library.”, { “OK” } )
end
return true
end
end[/lua]