Android:在内部存储中保存两个具有相同名称的位图 [英] Android: Save two Bitmaps with same name in internal storage
本文介绍了Android:在内部存储中保存两个具有相同名称的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在内部存储中保存名为picture.jpg的位图,稍后我会保存另一个名为picture.jpg的位图,那么会发生什么呢?
第二个Bitmap会覆盖第一个Bitmap还是有两个同名的Bitmaps?
If I save a Bitmap called "picture.jpg" in internal storage and some steps later I save another Bitmap called "picture.jpg" too, what happens then? Does the second Bitmap overwrite the first or are there two Bitmaps with the same name then?
推荐答案
它会显示你错了,我建议你可以使用动态文件名或在保存前删除它,在动态的情况下,你可以使用这样的东西:
It will show you an error, I suggest you could use a dynamic file name or delete it before saving, in the case of dynamic, you could use something like this:
static int fCount = 0;
File file = new File(Environment.getExternalStorageDirectory()
+ File.separator + "/test" + String.valueOf(fCount++) +".jpg" );
或
File file = new File(getExternalCacheDir(), "test.jpg" ); if (file.exists()) { boolean deleted = file.delete(); }
这篇关于Android:在内部存储中保存两个具有相同名称的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文