If we are trying to save to the gallery, we will move the temp file to localPath and insert the image info to the gallery database. If we don't want to save to the gallery, we don't do anything. All the temp files will be deleted in the method TiApplication.dispose() which is called from TiBaseActivity.onDestroy().