我使用以下代码获取存储在 SD 卡文件夹中的照片。这工作正常。但照片也存储在 SD 卡图像文件夹中,并显示在 androids 照片库中。为什么?
提前致谢!
public class Foto extends Activity implements SurfaceHolder.Callback,
OnClickListener {
private static final int CAMERA_ACTIVITY = 1;
private static final int TAKE_PICTURE = 1;
File archive, root, folder;
String fec;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
String storageState = Environment.getExternalStorageState();
if (storageState.equals(Environment.MEDIA_MOUNTED)) {
String path = Environment.getExternalStorageDirectory().getName()
+ File.separatorChar + "TEST" + "/"
+ "test.jpg";
archive = new File(path);
try {
if (archive.exists() == false) {
archive.getParentFile().mkdirs();
archive.createNewFile();
}
if (archive.exists() == true) {
archive.createNewFile();
}
} catch (IOException e) {
Log.e(ACTIVITY_SERVICE, "Could not create file.", e);
}
Log.i(ACTIVITY_SERVICE, path);
Uri _fileUri = Uri.fromFile(archive);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, _fileUri);
startActivityForResult(intent, TAKE_PICTURE);
setResult(RESULT_OK, intent);
finish();
} else {
new AlertDialog.Builder(Foto.this)
.setMessage(
"External Storeage (SD Card) is required.\n\nCurrent state: "
+ storageState).setCancelable(true)
.create().show();
finish();
}
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
}