3

I have a xamarin.forms app, I would like to allow users of app (android/ iOS/ windows) to be able to select a folder location at the start of the app and all the app related documents should be saved in that particular folder.

For now when I try to build a simple app which reads a xml file from the folder I create and display data on a list-view. I browsed through the file manager in android to see where the file is located physically on android device, but could not find any folder with app name.

In simple words I want a folder on the device to be created, which will be selected by the user. And accessible from file manager.

The reason behind this requirement is, the app is going to record a mp3 file and save a recording to a selected folder. So whenever the user wants to change his mobile he can always copy the recording to the new mobile and not loose any of the recordings.

Arti
  • 2,993
  • 11
  • 68
  • 121
  • 1
    on iOS an app can only access its own sandboxed file system. If you save the files in the app's document directory then it will be backed up and transferred if the user restores that backup on another device. – Paulw11 Feb 16 '16 at 08:13

1 Answers1

2

To be able to use any of the possibilities below you will have to write platform-specific code in Xamarin.Forms and then expose some interface that you can use back in your PCL project.

Android:-

There is a post Choose File Dialog on how to create a file dialog selector (with directory changer), although not in Xamarin.

You will want to point the starting location to a shared folder of some kind.

There is a Xamarin tutorial here that walks you through how to create a simple file browser.

iOS:-

For iOS you may be interested in the iOS Document Picker View Controller, here.

There is an extensive tutorial of how to complete this using Xamarin here.

enter image description here

(pictures are from Xamarin website)

Community
  • 1
  • 1
Pete
  • 4,746
  • 2
  • 15
  • 21
  • Thank you for quick response. Java is not my area, I will try to understand xamarin android and ios code. – Arti Feb 16 '16 at 11:08
  • I am very thankful to efforts you took to send me the reference links, but since I am new to this framework could you please brief me on how to use it in Xamarin.forms? – Arti Feb 16 '16 at 12:00
  • @Arti You will have to create an interface of common methods / properties that are implemented on each platform. Once done you can then write and expose. It's not going to be a simple and easy task though, by the looks of things, and will take quite a bit of effort. – Pete Feb 16 '16 at 12:11
  • So would the option of having a particular folder (a fixed folder) to save all the recording files would be a better option? – Arti Feb 16 '16 at 12:25
  • Are there any plugins available for this feature? – Arti Feb 17 '16 at 06:45
  • @Arti A fixed folder would be simpler. I have no idea if there are any plugins available for this feature as I haven't researched it. – Pete Feb 17 '16 at 10:10