0

my app, at first user login, downloads zip file.

Some users experienced disappearing this zip file. I found that sometimes device maintenance removes this zip.

How to prevent from deleting my zip file?

EDIT: User log in in my app. After successfull login my app downloads zip file with videos which are necessary. For downloading file I use DownloadManager. I save file in

Environment.getExternalStorageDirectory() + "/Android/data/" + BuildConfig.APPLICATION_ID + "/files/"

At the beginning it works well but after some time (let's say one week), this downloaded file disappears and user needs to download it one more time.

mateusz-dot
  • 186
  • 2
  • 9

2 Answers2

1

You do not need to use external disk space if you want to store files that do not need to remove. Choose internal space for that purposes. Also see.

  • As I know (maybe I'm wrong) but internal space isn't so big in some phones? My zip file is quite big - 700 MB – mateusz-dot Feb 09 '18 at 09:56
  • @mateusz-dot What if there is no external memory?? Also that is a big file you got there, I'm not sure that is a good idea for your app to constantly depend on a 700MB file, don't you agree? – DPE Feb 09 '18 at 09:59
  • @mateusz-dot Yes, you are absolutely right, but in this form this problem seems unsolvable. Files on the external storage can be deleted at any time. Nobody guarantees the safety of data. Maybe you should try to check for this archive and download it again if it is not on the disk. – Alexander Dadukin Feb 09 '18 at 10:00
  • @Darko +1. I am agree with u. – Alexander Dadukin Feb 09 '18 at 10:01
  • @Darko I agree, but it's impossible to run app without this 700MB file. This file contains all necessary files. – mateusz-dot Feb 09 '18 at 10:03
  • @mateusz-dot what kind of files? – DPE Feb 09 '18 at 10:04
  • Videos and images which are foundation of this app - main goal of this app was to run without internet. Trust me, unfortunately without this file, app won't work. – mateusz-dot Feb 09 '18 at 10:07
0

Maybe if the zip file contains something important to the app, its a good idea to extract that data, parse and store it to a database or something similar. That way you will always have your data. If you must store your file, here is the doc to the ways you can store data in android:https://developer.android.com/guide/topics/data/data-storage.html or maybe try hiding the folder and files from your users, if you dont want them to mess with your files, here is the way that is done.

Hope I helped

DPE
  • 218
  • 5
  • 15
  • Extracting isn't good option for me because my file is 700MB big and for extraction I would need 700MB * 2 = 1,4 GB – mateusz-dot Feb 09 '18 at 10:08
  • @mateusz-dot how can you access the files inside the zip then? At some point you must extract them.. Are you extracting the files always when the user starts the app? – DPE Feb 09 '18 at 10:18
  • If zip file doesn't have compression, you can access files without extracting. – mateusz-dot Feb 09 '18 at 10:24