2016-07-30 30 views
0

我正在從服務器下載圖像並將其保存在內部存儲器中。但我想隱藏圖庫中的這些圖像。我怎樣才能做到這一點?如何在Android中隱藏圖庫中的圖像?

我聽說命名文件夾.DirName隱藏圖像,但它不起作用在我的情況。 (電話不是源於)

public void myDownload(String myURL) { 

    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(myURL)); 
    //request.setTitle("File Download"); 
    //request.setDescription("Downloading...."); 

    //request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI); 
    request.allowScanningByMediaScanner(); 
    //request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); 
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN); 
    String nameOfFile = URLUtil.guessFileName(myURL, null, MimeTypeMap.getFileExtensionFromUrl(myURL)); 

    //request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getPath() + "/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile); 
    //request.setDestinationInExternalPublicDir("/MyDataFinal/", nameOfFile); 
    request.setDestinationInExternalPublicDir("/KiiTTimeTableData/Data/", nameOfFile); 

    DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); 
    manager.enqueue(request); 
} 

回答

0

您可以嘗試在你的照片文件夾中創建一個文件名.nomedia(包括前綴點)。這將阻止Android的媒體掃描器讀取您的媒體文件,並將其包含在圖庫或音樂等應用中。

另一種方法,你可以嘗試加密你的文件,閱讀這篇文章:How to encrypt file from SD card using AES in Android?