Thanks a lot. I got it working now. On May 3, 10:41 am, niko20 <[email protected]> wrote: > Hi, > > Starting with 1.6 you need to add the WRITE_EXTERNAL_STORAGE > permission to your android manifest, otherwise your app wont get > access to the sdcard. Google it or search in the dev docs for that > permission to see about it. > > -niko > > On Apr 29, 9:23 pm, Lynn Ooi <[email protected]> wrote: > > > > > Hi all, > > > I'm new in android and i had a problem saving the images into the > > sdcard. The code i had works find in my apps when i build it on > > android 1.5. Once i chance to android 2.0, it was not working. The > > both code is similar. However, in android 2.0, it says that the > > filenotfoundException: sdcard. Can anyone please help me here? > > > Here is part of the code: > > > void downloadFile(String fileUrl) { > > URL myFileUrl = null; > > String filepath = > > Environment.getExternalStorageDirectory().getAbsolutePath(); > > File wallpaperDirectory = new > > File(Environment.getExternalStorageDirectory().getAbsolutePath()); > > wallpaperDirectory.mkdirs(); > > File outputFile = new File(wallpaperDirectory, filename); > > > try { > > myFileUrl = new URL(fileUrl); > > } catch (MalformedURLException e) { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > try { > > HttpURLConnection conn = (HttpURLConnection) > > myFileUrl > > .openConnection(); > > conn.setDoInput(true); > > conn.connect(); > > > InputStream is = conn.getInputStream(); > > > bmImg = BitmapFactory.decodeStream(is); > > > FileOutputStream fos = new > > FileOutputStream(outputFile); > > bmImg.compress(CompressFormat.JPEG, 75, fos); > > fos.flush(); > > fos.close(); > > } catch (IOException e) { > > // TODO Auto-generated catch block > > error_msg = e.toString(); > > e.printStackTrace(); > > } > > try { > > Context context = > > WallpapersFile.this.getBaseContext(); > > new MediaScannerNotifier2(context, filepath + "/" + > > this.filename, > > "image/jpeg"); > > > // displaying download completion message > > AlertDialog.Builder builder = new > > AlertDialog.Builder(this); > > builder.setMessage("Wallpaper > > Downloaded").setCancelable(false) > > .setPositiveButton("ok", > > new > > DialogInterface.OnClickListener() { > > public void > > onClick(DialogInterface dialog, > > > > int id) { > > > > dialog.cancel(); > > } > > }); > > AlertDialog alert = builder.create(); > > alert.show(); > > } catch (Exception e) { > > Log.e("MyLog", e.toString()); > > has_error = true; > > } > > } > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Beginners" group. > > > NEW! Try asking and tagging your question on Stack Overflow > > athttp://stackoverflow.com/questions/tagged/android > > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group > > athttp://groups.google.com/group/android-beginners?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow > athttp://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group > athttp://groups.google.com/group/android-beginners?hl=en
-- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

