2013-02-18 84 views
0

我製作了一個照相機應用程序並將圖像保存在DCIM/Yogyakarta中,但無法打開該目錄。它只能在DCIM /打開。打開圖片庫Android

任何人都可以告訴我爲什麼我無法打開目錄,我該如何修復它?

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); 
     } 
    }); 

回答

1

只是下面@

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

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

它需要 「/」 來獲取正確的路徑替換您getAlbumStorageDir方法。

+0

謝謝您的回答..但 畫廊仍然沒有在DCIM/Yogyakarta上顯示圖片。 – xniclez 2013-02-18 11:08:05

+0

它應該工作,我在2.2版本中測試過。無論如何,您正在測試哪種設備或平板電腦? – RobinHood 2013-02-18 11:09:31

+0

我想那樣..,我在2.2測試和使用S.E Neo V OS.2.3.4 – xniclez 2013-02-18 11:12:59