简体   繁体   English

Android将文件推送到文件夹

[英]Android pushing files to folders

How to categorize files once I push them to the SD CARD. 将文件推送到SD卡后如何对文件进行分类。 In case if I push a file with extension *.mp4 it should go to the music folder accordingly…Likewise all other files should go to their respective folders in the phone. 如果我将扩展名为* .mp4的文件推送到音乐文件夹中,则…相应地,所有其他文件也应转到手机中的相应文件夹中。

Do we need to create separate directories in order to achieve it 我们是否需要创建单独的目录才能实现它

You can create directories based off of the suffix part of the file. 您可以基于文件的后缀部分创建目录。 Depending on the suffix, add the file to an appropriate directory name. 根据后缀,将文件添加到适当的目录名称。 If there is a conflict with that directory name just add the file to that directory, otherwise create a new directory and add it to the newly created directory. 如果与该目录名称存在冲突,只需将文件添加到该目录中,否则创建一个新目录并将其添加到新创建的目录中。 For example, a very simple example would look like: 例如,一个非常简单的示例如下所示:

File dir = new File("Music");
if (!dir.exists()){
    //code here
}else{
   //code here
}

I don't think there's anything such as automatic categorize of files... 我认为没有诸如文件自动分类之类的功能...

What I would do is to create a method that will take the file name as input parameter and return path to the respective folder 我要做的是创建一个将文件名作为输入参数并返回到相应文件夹的路径的方法

Implement a switch 实施开关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM