views:

44

answers:

1

My Application downloads a file from a server and stores it in: /mnt/sdcard/Android/data/com.test/files. (the /mnt/sdcard is derived from Environment.getExternalStorageDirectory(); )

Everytime I redeploy the Application from eclipse(run menu) to the emulator it deletes the file. The Checkbox 'target/wipe user data' in the run configuration is unchecked. I close all the BufferedOutputStreams properly so I don't think it is my application itself. Am I using the right directory for persistent data storage? (my Files are around 70-100M)

Any hints?

+1  A: 

From the getExternalStorageDirectory's doc:

Applications should not directly use this top-level directory, in order to avoid polluting the user's root namespace. Any files that are private to the application should be placed in a directory returned by Context.getExternalFilesDir, which the system will take care of deleting if the application is uninstalled. Other shared files should be placed in one of the directories returned by getExternalStoragePublicDirectory(String).

Your /mnt/sdcard/Android/data/com.test/files should be in your Context.getExternalFilesDir() and it gets deleted when the app is uninstalled.

Macarse