[android-developers] Save to SD

2011-05-21 Thread kypriakos

I am saving jpeg image on sdcard through an activity - about 1 MB
takes literally
close to an hour ... is that normal?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Save to SD

2011-05-21 Thread Mark Murphy
On Sat, May 21, 2011 at 1:55 PM, kypriakos demet...@ece.neu.edu wrote:
 I am saving jpeg image on sdcard through an activity - about 1 MB
 takes literally
 close to an hour ... is that normal?

No.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] save to sd

2010-08-26 Thread charles berman
I am struggling with this, if the image doesnt exist hello.jpg it does
create a new file, but when i execute the line of  FileOutputStream out =
new FileOutputStream(file);, i get a filenotfoundexception.

public static Bitmap getImage(String fileUrl)
{
Bitmap bitmap = null;
 InputStream in = null;
URL url;
 // Check to see if image allready exists
String imgName = fileUrl.substring(fileUrl.lastIndexOf(/)+1);
 String sdPath = /Barfly/+imgName;
 File imgFile = new File(sdPath);
 if (imgFile.exists())
{
 bitmap =  BitmapFactory.decodeFile(sdPath);
}
else
 {
try {
url = new URL(fileUrl);
 URLConnection ucon = url.openConnection();
in  = ucon.getInputStream();
 bitmap = BitmapFactory.decodeStream(in);
in.close();
File path = Environment.getExternalStorageDirectory();
 File dir = File(path,Barfly);

File file = new File(dir,imgName);
 boolean result = file.mkdirs();
result = file.createNewFile();
  try
{

 FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
}
catch (Exception e) {
   e.printStackTrace();
}
  }
catch (MalformedURLException e)
 {
 e.printStackTrace();
 }
catch (FileNotFoundException e)
{
 e.printStackTrace();
}
 catch (IOException e)
{
}
 catch (Exception e)
{
e.printStackTrace();
 }
}
 return bitmap;
 }
Charles Berman
313.790.9851

www.charlesberman.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en