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 at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en