I have a application requirement in Android. In my application I want to add files as attachments. This is to have it for quick reference.
In my layout I want to have a attach button. If the user clicks on the attach button he should get a file browser to browse the SD CARD. He must be able to select a file to attach.
I am not sure where to start of this code. I have placed a button and have a on click listener. But Inside the on click listener I am not sure what has to be done. Can you help me with some sample code or some links that can help me do it. Any kind of help is appreciated. Thank you.
You need an
Intentto open up a file chooser. This is assuming the user has a file chooser.Note
reqCodeis like a ‘key’ you use later. Next you’ll overrideonActivityResult()in yourActivity. When it runs, check to see if therequestCodematches yourreqCode. If it doe, you know it’s from your intent, and can get the data packed in the incoming intent.This is just a brief overview, you should probably read up more on intents in the official documentation.