I try to download an image with this code and save it : in this line:
OutputStream os =new FileOutputStream(f);
i try it on the emulator.my
Try this to get the folder (and create it if it doesn't exist) and then use the f File var as you were doing in your code:
File cacheDirectory;
if ( android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED ))
cacheDirectory = new File( android.os.Environment.getExternalStorageDirectory(), "myFolder/" );
else
cacheDirectory = this.getCacheDir();
if( !cacheDirectory.exists() )
cacheDirectory.mkdirs();
File f = new File( cacheDirectory, "my_file.jpg" );
Read the link for getCacheDir()
:
http://developer.android.com/reference/android/content/Context.html#getCacheDir%28%29