i tried save photo to sd card and on htc device all ok . I see my photo on sd card and when open i see my photo. But when i tried it on galaxy tab , photo are saved but when i open this photo i see only black screen. Can any tell how to fix it ?
my code
tempBMP.compress(Bitmap.CompressFormat.JPEG, 85, stream);
log("stream3");
File saveDir=null;
String filename="";
byte[] byteArray = stream.toByteArray();
try
{
if (!saveDir.exists())
{
saveDir.mkdirs();
}
FileOutputStream os = new FileOutputStream(String.format("/sdcard/ "+""+filename, System.currentTimeMillis()));
os.write(byteArray);
os.close();
}
catch (Exception e)
{
}
regards, Peter.
I don't really know why, but this code works for me. Maybe you should use Enviroment.getExternalStorageDirectory()
rather than use "/sdcard/". Try it.
File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath());
dir.mkdirs();
File out = new File(dir,filename);
try {
out.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
DataOutputStream fo = null;
try {
fo = new DataOutputStream( new FileOutputStream(out));
//write what you want to fo
fo.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}