现在我写了一段程序,已知像素值想把它保存成图片并保存到SD卡上,
class SaveButtonlistener implements OnClickListener { @Override public void onClick (View v) { //TODO Auto-generated method stub if(b!=2) Toast.makeText(second.this,"请先从执行前面的操作", Toast.LENGTH_SHORT).show(); else{ Toast.makeText(second.this,"开始检查SD卡", Toast.LENGTH_SHORT).show(); String sdStatus = Environment.getExternalStorageState(); if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) // 检测sd是否可用 Log.v("TestFile","SD card is not avaiable/writeable right now."); else{ FileOutputStream fill = null; File file = new File("/sdcard/image/"); try { Toast.makeText(second.this,"开始啦", Toast.LENGTH_SHORT).show(); file.mkdirs();// 创建文件夹 String fileName = "/sdcard/image/1111.png"; fill = new FileOutputStream(fileName); Bitmap bmp = Bitmap.createBitmap(spic.pixel, spic.width, spic.height, Bitmap.Config.ARGB_8888); bmp.compress(Bitmap.CompressFormat.PNG, 100, fill);// 把数据写入文件 fill.flush(); fill.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } //finally { // try {} catch (IOException e) { e.printStackTrace(); Toast.makeText(second.this,"异常抛出啦!!!!问题没有解决,加油吧", Toast.LENGTH_SHORT).show(); } } Toast.makeText(second.this,"保存成功,文件名为image/1111.png", Toast.LENGTH_SHORT).show(); } }
这是代码,手机提示我保存成功,但手机里确实找不到,哪位大侠可以帮忙看看啊