0

我制作了一个相机应用程序并将图像保存在 DCIM/Yogyakarta,但我无法打开该目录。它只能在 DCIM/ 中打开。

谁能告诉我为什么我无法打开目录,以及如何修复它?

public final class FroyoAlbumDirFactory extends AlbumStorageDirFactory {

@Override
public File getAlbumStorageDir(String albumName) {
    // TODO Auto-generated method stub
    return new File(
      Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_DCIM
      ), 
      albumName
    );
 }
}


@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mAlbumStorageDirFactory = new FroyoAlbumDirFactory();


    Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture);

    buttonLoadImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
        storageDir = mAlbumStorageDirFactory.getAlbumStorageDir("Yogyakarta");              

            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(storageDir),"*/*");

            startActivityForResult(intent, RESULT_LOAD_IMAGE);
         }
    });
4

1 回答 1

1

只需将您的getAlbumStorageDir方法替换为以下@

public File getAlbumStorageDir(String albumName) {
        // TODO Auto-generated method stub

        return new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),"/"+ albumName);
     }

它需要“/”来获取正确的路径。

于 2013-02-18T10:58:13.083 回答