扫描Android的SD卡的新文件 [英] Scan Android SD card for new files

查看:158
本文介绍了扫描Android的SD卡的新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序允许用户将图像保存到他们的SD卡。但我不知道怎么做,直到你卸载并重新挂载SD卡也出现在画廊。我用Google搜索了这个问题了两天,但我不知道如何使它自动出现。我发现 的链接,但我不知道如何使用类。这是我用什么来保存文件。在try catch块的底部是我想要的扫描SD卡新媒体。

My app allows a user to save an image to their SD card. But I'm not sure how to make it appear in the gallery until you unmount and remount the SD card. I have googled for a couple of days with this problem but am not sure how to make it appear automatically. I found this link but I'm not sure how to use the class. This is what i use to save the file. At the bottom of the try catch block is where I want to scan the sd card for new media.

    FileOutputStream outStream = null;
    File file = new File(dirPath, fileName);
    try {
        outStream = new FileOutputStream(file);
        bm.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
        outStream.flush();
        outStream.close();
    } catch {
         ...
    }

如果任何人都可以点我在正确的方向,我想AP preciate。

If anyone could point me in the right direction, I would appreciate.

推荐答案

由于最后的答案我张贴显然不是一个合适的方法,我发现了另一个方法<一href="http://stackoverflow.com/questions/4157724/dynamically-add-pictures-to-gallery-widget">here.基本上,你创建一个包装类,对其进行初始化,然后调用扫描()方法。非常有帮助的帖子。让我知道这是不恰当的无论是。

Since the last answer I posted apparently wasn't an appropriate method, I found another method here. You basically create a wrapper class, initialize it, and then call the scan() method. Very helpful post. Let me know if this isn't appropriate either.

这篇关于扫描Android的SD卡的新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆