【问题标题】:Open Folder specifed in edittext android打开edittext android中指定的文件夹
【发布时间】:2013-12-16 08:03:54
【问题描述】:

我正在努力展示来自画廊的图片下面是代码。 在这里,我想打开特定文件夹中的图像,该文件夹的名称将在编辑文本中给出。 请帮助我这样做,因为它目前打开所有与应用程序无关的图像并且我很难识别图像。

protected void LoadGalleryImages() {
        final String[] columns = { MediaStore.Images.Media.DATA,
                MediaStore.Images.Media._ID };
        final String orderBy = MediaStore.Images.Media._ID;
        imagecursor = managedQuery(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
                null, orderBy);
        int image_column_index = 0;

        if (imagecursor != null) {
            image_column_index = imagecursor
                    .getColumnIndex(MediaStore.Images.Media._ID);
            count = imagecursor.getCount();
        }

        imgSelected = new String[count];

        arrPath = new String[count];
        thumbnailsselection = new boolean[count];
        for (int i = 0; i < count; i++) {
            if (imagecursor != null) {
                imagecursor.moveToPosition(i);
                // int id = imagecursor.getInt(image_column_index);
                int dataColumnIndex = imagecursor
                        .getColumnIndex(MediaStore.Images.Media.DATA);

                arrPath[i] = imagecursor.getString(dataColumnIndex);
            }

        }
    }

【问题讨论】:

    标签: android android-imageview android-image android-file android-external-storage


    【解决方案1】:

    普佳,

    这是打开指定文件夹以浏览文件的代码:

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse("folder path");
    
    //Change content type as you want if you dont know then just mention "*/*"
    intent.setDataAndType(uri, "text/csv");
    
    startActivity(Intent.createChooser(intent, "Open folder"));
    

    希望这会对你有所帮助。

    【讨论】:

    • 你的意思是,这段代码在哪里写?如果是,那么只需用我的代码替换“LoadGalleryImages()”的定义。它应该可以工作。
    • 我在下面的链接stackoverflow.com/questions/14200309/…得到了解决方案
    • 太棒了@Pooja。祝你好运
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 2010-12-28
    • 2018-03-02
    • 2021-03-08
    相关资源
    最近更新 更多