Programmatically created Image folder not shown in the Public folder

徘徊边缘 提交于 2019-12-08 12:59:39

问题


I'm new to Android Development. I have developed a program that capture images via camera and stored in mnt/sdcard/Pictures/MYFOLDER. And also there is another button foe browse images. image save perfectly. But when I browse the taken images by clicking Browse button it only shows these folders: Pictures,Bluetooth,images. When I navigate to Pictures folder MYFOLDER does not exist.

here is my Browse button

 Button buttonLoadImage = (Button) findViewById(R.id.btnBrowseimage);
        buttonLoadImage.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                Intent i = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

                startActivityForResult(i, RESULT_LOAD_IMAGE);
            }
        });

Please guide me.


回答1:


Some times it happens that gallary not show the newly created directory. I don't know why but may be due to not scanned newly created/modified directory.

Solution

Restart your device.




回答2:


Instead of restarting fire this broadcast which will help re-indexing of the newly created folder or file and the resulting folder will be visible in the gallery:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mediaMountUri));


来源:https://stackoverflow.com/questions/21473185/programmatically-created-image-folder-not-shown-in-the-public-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!