I have never used an enum before. So please be patient with me a little bit.
App background:
I created an application in which the user can add three type of sources, *music* *video* and *pictures* from the external storage USB device.
The user selects a folder onto the usd drive and adds it to the source and then adds a category for it.
THIS HAS BEEN DONE
The Issue is
Now I am trying to read all the files from the folder which has a specific extension, as defined by category.
Following are the extensions for three categories that will be stored in an xml file
<?xml version="1.0" encoding="UTF-8"?>
<Picture>
<ext>jpg</ext>
<ext>png</ext>
<ext>gif</ext>
<ext>jpeg</ext>
<ext>pdf</ext>
<ext>pcd</ext>
<ext>jpx</ext>
<ext>tif</ext>
</Picture>
<Videos>
<ext>mpeg</ext>
<ext>mpg</ext>
<ext>mpe</ext>
<ext>mpeg-1</ext>
<ext>mpeg-2</ext>
<ext>mp4</ext>
<ext>mpa</ext>
<ext>wmv</ext>
<ext>wma</ext>
<ext>wmx</ext>
<ext>rm</ext>
<ext>ra</ext>
<ext>3gp</ext>
</Videos>
<Music>
<ext>mp3</ext>
<ext>wav</ext>
<ext>dct</ext>
<ext>gsm</ext>
<ext>flac</ext>
<ext>au</ext>
<ext>ogg</ext>
<ext>raw</ext>
<ext>wma</ext>
<ext>msv</ext>
</Music>
So, for instance, if a user has selected the video category I will read all files which have the extensions similar to video in my xml
My Qustion Is:
I am trying to do this thing by using an ENUM, I know I can do it with simple if/else statements as well, but I need to know how the ENUM will work.
I have created a Media Source Enum that has the categories defined.
Here is the code:
public enum Media_source {
Pitures("P"), Videos("V"), Music("M");
private String statusCode;
private Media_source(String s) {
statusCode = s;
}
public String get_media_source() {
return statusCode;
}
}
Then I have a Source class that checks which category is selected.
public class Source {
public static String source_path;
public static String source_name;
Media_source mSource;
public static void main(String[] args) {
System.out.println(Media_source.Pitures.get_media_source());
}
public Source(String name, String path) {
Source.source_name = name;
Source.source_path = path;
}
public static String getSource_path() {
return source_path;
}
public static void setSource_path(String source_path) {
Source.source_path = source_path;
}
public static String getSource_name() {
return source_name;
}
public static void setSource_name(String source_name) {
Source.source_name = source_name;
}
}
Now how can I actually select all files with the extensions for the selected category?
How should I use the enum?
I am not asking for code, though any helping material would be appreciated - I just need to get the concept clear.
Thank you