I would like to create a button that when clicked will go to a class that displays all media files from an SD card using a ListView.
After selecting from the list it will then return the filename selected to the main class. IF the returned file is an image file, it will be displayed in an ImageView and if the returned file is an audio file, it'll display and on click play?
You may find it interesting to use a library to consult the files in a directory and display it. This can save you lots of work if the requirements of your application permits. There are a lot of libraries for this pourpose, for example:
https://github.com/bartwell/ExFilePicker
Hope it helps you!!
Related
I am developing a Note App that store file in external sd card. File Management is also a part of app. App allow user to create folder. I use this code.
file.mkdir();
After that I refresh my ListView;
I can see newly created folder in listView. But i can't acess it( click it) immediately. I have to wait for a while to be able to access it. Please help me out..
The problem is solved.
Before setting new adapter to listView, set null to setAdapter().
I add
listView.setAdapter(null);//this make listView empty
listView.setAdapter(adapter);//fill listView with new Data..
i m working on a project in which i have to store and read some list elements in xml format i did the prasing part by creating file in res/xml and and using getResources().getXml(R.xml.SAMPLEFILE); it works well.. problem arise when i go for file creation..i m unable to find tutorial which lets u creat or open(if already created) xml in res/xml..
http://www.anddev.org/write_a_simple_xml_file_in_the_sd_card_using_xmlserializer-t8350.html
You cannot add anything to your res folder during runtime. If you want the xml to be stored there you'll have to add it in when you compile. If you need it to be dynamic then you'll have to store the xml file in a different place.
One option you have is private internal storage for your application. Check out this page
for an overview of how to save to and read from this internal storage.
I have a layout where users can add buttons and place them where they want.
I want to allow the user to save their layout so that it is loaded the next time they open the app.
Does anyone know if I can save the file on the sdcard? Alternatively I could use some kind of layout.getXml() method and put it in the database my app uses.
Thanks in advance
There is no file to save when you are generating a layout via code. You will have to create your own file format, which could be saved to the SD card or inserted into a database.
You can us savedInstaceState() method with the same type object as parameter .
there load the ui you want at the time of reloading.
In onCreate() method put a condition whethere that savedInstaceState obj is null or not . if not then call the LoadUI().
If I were you, I would create a class holding all the information about this layout and buttons. And write every information of the class to a file with JSONWriter. When the app has opened I just read the file and recreate the arrays using JSONObjects.
i want to show the details of the file or folder after selecting that.
eg.Long press on a file say "icon.jpg" and we have some info like size,type,dateTime Modified,last opened,
hidden or not,permissions etc.
please help me by some example.
Jokes apart. You need to create your own file browser. Also read about creating context menus
I am new to this android application development.
I have a audio files in a particular directory. I want to list the those audio files in a listView.
please tell me how to do this activity.
Create a File object representing your directory on the SDcard and call appropriate File#list() variant to get list of all the files in that directory. You will get names of the files in a String[].
Create an Adapter class and pass this String array to it. Make a ListView and back it up by this custom Adapter.You can refer examples in API demos or this tutorial for the same