我有ListView,相机按钮,从图库按钮和保存按钮中选择。 从ListView保存图像已完成工作。但我需要画廊中的原始图像名称而不是自己输入名称。有什么建议吗?
以下是从ListView保存图像的编码:
public void onClick(DialogInterface dialog, int which) {
String dateN = getIntent().getStringExtra("the_date");
View content = findViewById(R.id.imgView);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File root = Environment.getExternalStorageDirectory();
File cachePath = new File(root.getAbsolutePath() + "/CalendarNote/" + dateN + "01.jpg");
boolean success = true;
try
{
cachePath.createNewFile();
FileOutputStream ostream = new FileOutputStream(cachePath);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
if (success) {
Toast.makeText(getBaseContext(), "You have successfully saved image." , Toast.LENGTH_SHORT ).show();
}
else {
Toast.makeText(getBaseContext(), "You have Failed to save." , Toast.LENGTH_SHORT ).show();
}