我像这样存储相机拍摄的照片:
FileOutputStream out = new FileOutputStream("img_example");
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
在 onCreate() 方法(同一个活动/文件)中,我检查文件是否存在,但我一定做错了,因为它没有进入以下测试:
file = getApplicationContext().getFileStreamPath("img_example");
if(file.exists())
{
//doesn't go in here
}
我怀疑这与我给出的路径或上下文有关。
背景信息:我实际上有上述代码的 3 个不同实例。在 file.exists() 测试中,我在“拍摄图像”按钮旁边显示一个勾号。最终,我想在另一个活动中检索图像,但现在我只想检查它是否存在