如何创建android的Gallery应用程序特定的文件夹? [英] How to create application specific folder in android gallery?

查看:134
本文介绍了如何创建android的Gallery应用程序特定的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立Android应用程序 XYZ ,其中用户将存储介质如图像和视频。因此,我想在XYZ文件夹中创建名为XYZ的Andr​​oid库和店里所有的媒体特定于应用程序。我该如何实现呢?

I'm building android application "XYZ" in which users will be storing media such as images and videos. Therefore, I would like to create a folder in android gallery named "XYZ" and store all the media specific to the application in "XYZ". How do I achieve it?

目前,我可以存储在SD卡和扫描媒体文件的媒体,他们出现在图片文件夹,在Android的画廊。

Currently, I'm able to store the media on sdcard and on scanning the media files, they show up in "images" folder, in android gallery.

推荐答案

我猜存储您的图片由画廊到达写入文件到该目录。的正确方法

I guess the proper way of storing your images accessible by galleries is writing the files to this directory.

static final String appDirectoryName = "XYZ";
static final File imageRoot = new File(Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_PICTURES), appDirectoryName);

和用于视频

static final File videoRoot = new File(Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_MOVIES), appDirectoryName);

和创建映像

imageRoot.mkdirs();
final File image = new File(imageRoot, "image1.jpg");
// open OutputStream and write the file

如果你添加一些文件,并打开您应该看到专辑XYZ的画廊。 请注意,你不会看到这张专辑,如果该目录是空的。

If you add some files and open the gallery you should see album "XYZ". Note that you will not see the album if the directory is empty.

和你的话

目前,我可以存储在SD卡和扫描的介质   媒体文件,它们显示在图片文件夹,在Android的画廊。

Currently, I'm able to store the media on sdcard and on scanning the media files, they show up in "images" folder, in android gallery.

重新presentation取决于你使用的库的应用程序。 默认的Andr​​oid库应建立相册媒体文件的文件夹的名字命名的。

The representation depends on the Gallery app you use. The default Android gallery should create "Albums" named after the folder the media files are in.

编辑:你不会看到新创建的图像,如果你不运行介质扫描仪或将其添加到MediaStore数据库

you will not see newly created image if you don't run media scanner or add it to MediaStore database.

这篇关于如何创建android的Gallery应用程序特定的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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