我正在保存图像代码...它具有框架布局和叠加图像..它工作得很好,但它保存在根文件夹中,我想将它保存在sdcard/my_photos中,这是我的代码:
FrameLayout mainLayout = (FrameLayout) findViewById(R.id.frame);
Random fCount = new Random();
int roll = fCount.nextInt(600) + 1;
File file = new File(Environment.getExternalStorageDirectory()
+ File.separator + "/ghost" + String.valueOf(roll) +".png" );
Bitmap b = Bitmap.createBitmap(mainLayout.getWidth(),
mainLayout.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
mainLayout.draw(c);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
if (fos != null) {
b.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
}
} catch (Exception e) {
e.printStackTrace();
}
请帮帮我。