Android SD card created file not visible

后端 未结 2 1458
面向向阳花
面向向阳花 2021-01-21 15:44

I\'ve created a file in the SD card using the code below:

File outputFile = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separato         


        
相关标签:
2条回答
  • 2021-01-21 16:16

    image files need to be explicitly indexed in order to appear in the gallery. I suppose other applications may be using the same mechanism to get the thumbnail. Here is some code that will scan a new media file, right after you wrote it:

     Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
     Uri uri = Uri.fromFile(outputFile);
     intent.setData(uri);
     sendBroadcast(intent);
    
    0 讨论(0)
  • 2021-01-21 16:22

    Maybe there is some Windows caching behind in order not to continuously poll the directory listing. Try hitting F5 in Explorer to see if file comes up. In any case, file should be visible in Eclipse's phone File Explorer (in DDMS Perspective).

    0 讨论(0)
提交回复
热议问题