I plan on making an app for a church, and it's pretty much a relatively simple one, it's just going to have a menu in the main xml which will contain an about section contact and a clips section. now when the user clicks on clips they will be redirected to an xml file listing all the audio clips for the services of prior weeks which the user can then click to listen to. i was just planning on creating a raw folder and placing all clips inside that folder and then accessing the audio files through the mediaplayer class with a raw. method, but would that really be the best way of doing it? I have several questions here. If i do it that way would I have to modify the code all of the time because i would have to insert the newest clips? if so what is a better way of doing this so i don't have to continuously have to change my code each week since i plan on inserting the newest audio clip from that weeks service?
2 Answers
Put all of your clips in the assets
folder.
In your app use something like:
AssetManager assets = getAssets();
String[] list = assets.list("");
This returns a list of all files in assets folder. Here you need to use that array in a list view or handle it to create views in whatever way you find appropriate.
The easiest would be to use a listView and literally put the file titles in the list by using the array in the adapter.
ListView listView = (ListView) findViewById(R.id.listView);
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
this,
android.R.layout.simple_spinner_item,
new ArrayList<CharSequence>(Arrays.asList(list)));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
listView.setAdapter(adapter);
When its time to use one of the files (perhaps in a ListView.OnItemSelectedListener()
):
assets.open(fileName);
fileName is a string containing the name of the file you have selected.
This method will not involve changing code when it is time to update.
If your app is going to exceed 50mb you will need to use an expansion file. This is method is a bit more complicated due to the expansion file downloading and verifying, but it is used in a similar way.

- 366
- 2
- 10
When you list the sound clips that the user can see, why don't you make it get this list by listing all of the music clips in a certain folder? Whenever you want to add a sound clip all you'll have to do is add it to that folder. Don't have any static references to specific sound clips.
Also, you may want to start accepting answers, or people are going to stop answering you. I'm not saying select mine as an answer (unless it's what you were looking for), but you might want to take a second and go through your past questions. A couple of them have some highly rated answers.

- 3,334
- 20
- 27
-
the only reason why i was planning on doing it this way was because a tutorial from a book did it that way. that is why i'm asking what a better way of doing it is. Do you have any links that could help me out or tutorials on getting a list so i can just do what you mentioned. that would help me out so much. thank you. – John Acosta Oct 06 '12 at 02:49
-
Google `ListView`. Here's an something that might help. http://stackoverflow.com/questions/9229516/using-listview-in-android – Michael Oct 06 '12 at 04:48