arungiri_10
arungiri_10

Reputation: 988

File path for android when using emulator

I am new to android. I am trying to download a file from server and save the file in a particular path. The application is working fine. However I am not able to find the path of the downloaded file. In the code I have given as

File output = new File("/data/data/com.test.firstApp/", fileName);

Where can i find the file on my system?

Upvotes: 3

Views: 14147

Answers (3)

falro
falro

Reputation: 125

Adding to Rich's answer, in the likely event you will end up writing to external storage make sure to include this permission in the manifest:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 1

Rich
Rich

Reputation: 36856

Don't use hard coded file paths. The framework will give you the base path of the area you want to save files to.

For the SD card, use Environment.getExternalStorageDirectory()

For local files, use Context.getFilesDir() (or Context.openFileOutput(String name, int mode), etc)

For local cache, use Context.getCacheDir()

Upvotes: 5

Michal
Michal

Reputation: 2084

Check this page http://developer.android.com/guide/topics/data/data-storage.html

You can find there many methods how to save file. What is more you can also read something about good practices.

Cheers

Upvotes: 0

Related Questions