So I got this working by changing the context.getCacheDir() to context.getExternalFilesDir(sdState) and now I can once again have my app download images from the web and take photos.
On Feb 16, 3:08 pm, Jim Andresakis <[email protected]> wrote: > Yeah I cant figure that out either. However it wasnt an issue up until > a week ago. > > This is what Im using to create the place that I thought would be the > sd card > > String sdState = android.os.Environment.getExternalStorageState(); > if (sdState.equals(android.os.Environment.MEDIA_MOUNTED)) { > File sdDir = > android.os.Environment.getExternalStorageDirectory(); > cacheDir = new File(sdDir,"data"); > } > else > cacheDir = context.getCacheDir(); > > if(!cacheDir.exists()) > cacheDir.mkdirs(); > > if(sdState.equals(android.os.Environment.MEDIA_MOUNTED)){ > File adSdDir = > android.os.Environment.getExternalStorageDirectory(); > adCacheDir = new File(adSdDir,"addata/"); > }else > adCacheDir = context.getCacheDir(); > > if(!adCacheDir.exists()) > adCacheDir.mkdirs(); > } > every where I read thats how you get to the sd card > > On Feb 16, 3:02 pm, Chris Mawata <[email protected]> wrote: > > > > > > > > > Your single application won't be given all of the 1 gig of memory on > > the device. It is a much more humble number like 16MB or 24MB. > > Probably the first thing to investigate is why the images are on > > internal memory. > > > On Feb 16, 5:21 pm, Jim Andresakis <[email protected]> wrote: > > > > Hello, > > > > I have an app where I let users take pictures and at the same time I > > > stream pictures to the user based on their location. Im storing the > > > image files from the download in a file that is supposed to be on the > > > sd card but for some reason gets created on the internal memory. Just > > > recently I hit a problem where suddenly after about 80 small image > > > files have been downloaded into the file my app will no longer allow > > > users to take images. I get no crash but just a warning in the logcat > > > that states > > > > Java.IO.Exception no space left on device > > > > This is happening when I am trying to create a file from an > > > outputstream. > > > > In my code this error happens at this particular line: > > > > bmp.compress(Bitmap.CompressFormat.PNG, 80, out); > > > > I have that line nested within a method that I use to create an image > > > that can be stored locally on the phone rather than in memory so I > > > dont run out of memory. > > > The whole method looks like this: > > > > private void writeFile(Bitmap bmp, File f) { > > > FileOutputStream out = null; > > > > try { > > > out = new FileOutputStream(f); > > > bmp.compress(Bitmap.CompressFormat.PNG, 80, out); > > > } catch (NullPointerException e) { > > > e.printStackTrace(); > > > Log.w("nullpointerException on image error", > > > "nullpointer"); > > > } catch (FileNotFoundException e) { > > > Log.w("fileNotfoundException on image error", > > > "filenotfound"); > > > // TODO Auto-generated catch block > > > e.printStackTrace(); > > > } > > > finally { > > > try { if (out != null ) out.close(); } > > > catch(Exception ex) {} > > > } > > > } > > > > both catches never hit when this method fails so I guess Im hitting > > > the final catch in the finally block. > > > I have done some research on this and I do not think Im running into > > > the problem of having to many files in one directory or using names > > > that are too long. The file names are 1 to 5 characters at most and > > > last week I was able to have over 400 files in the same directory > > > without any problems like this occurring. The phone Im testing on at > > > the moment has over 1gig free of internal and close to the same on the > > > external so hard memory is not the issue either. This is a sudden > > > problem that just came on last week so Im kind of stumped and any help > > > would be much appreciated. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

