2011-09-15 47 views
1

嗨我想要使圖像對Android圖庫或任何第三方圖庫應用程序不可見,圖像將被放置在SD卡上的特定文件夾中。將圖像和文件夾隱藏到保存在SDcard上的圖庫中?

例如,我有以下代碼將圖像保存到名爲myimages的文件夾中。我只是希望存儲在myimages文件夾中的圖像不應該對任何圖庫應用程序可見,並且只有我自己的應用程序才能訪問這些圖像。

void saveBitmap(Bitmap bmp) 
{ 
    FileOutputStream os; 
    String dirName = "/mvc/mvc/myiamges/"; 
      try { 
       if (android.os.Environment.getExternalStorageState().equals(
         android.os.Environment.MEDIA_MOUNTED)){ 
        String root = Environment.getExternalStorageDirectory() 
              .toString(); 
        File dir = new File (root + dirName); 

        boolean created=dir.mkdirs(); 
        //File file = new File(this.getExternalFilesDir(null), 
          //      this.dirName+fileName); 
          //this function give null pointer exception so im 
          //using other one 
        File file = new File(dir, "aeg2.png"); 
        os = new FileOutputStream(file); 
       }else{ 
        os = openFileOutput("aeg2.png", MODE_PRIVATE); 
       } 
       bmp.compress(CompressFormat.PNG, 100, os); 

       os.flush(); 
       os.close(); 
      }catch(Exception e){ 
       e.printStackTrace(); 
      } 
} 

回答

0

重命名這些文件中包含filename.extension.customextension

像hello.avi.topsecret自定義擴展。

當您需要文件準備就緒模式時,將其重命名爲適當的擴展名,然後播放並重新命名。

這應該適合你。

在文件夾名稱前加上一個點「。」。

檢查這些鏈接,瞭解更多信息:

http://www.makeuseof.com/tag/hide-private-picture-folders-gallery-android/

0

是的,你想,甚至沒有任何擴展名爲擴展名保存。

在您的應用中,只需將其作爲普通圖像文件閱讀即可。

相關問題