File dialog to pick a file from the device

Good day,

I was wondering if it is possible to open a “file picker” dialog that allows me to choose a file from the phones memory. I am thinking about an export/import function for a database. The export would be done via email, so that the database can be send as attachement in an email.

But how would I do the import?

If there is no option to access the phones memory, I will probably write some server based export/import functionality, but I would prefer not, at least for now…

Anybody has a solution for this?

Best,

Felix

You have access to three writable directories on iOS and two on Android:

system.DocumentsDirectory

system.TemporaryDirectory

system.CachesDirectory (points to system.TemporaryDirectory on Android)

The Documents directory is used to store permanent files. These will be backed up to iCloud on iOS unless you explicitly say not to. Apple does not want large amounts of data being backed up, so any big databases should be flagged to avoid backup.

CachesDirectory is where Apple wants any downloadable files to be downloaded. They can be replaced so if they get deleted, they can be recreated. TemporaryDirectory is for stuff that can be freely deleted.

We have a module called LFS (Lua File System) that you can use to get a list of files in these three folders (and any subfolders you make). You can use this to present a list of files to the users perhaps in a widget.newTableView().

Rob

Hello Rob, and thanks for you answer.

I ment something different, I think. I would need some place where I can copy data to (from outside the app), so that I can access it from within my app.

If these three are the only places where I have access to, I think I will have to create a server based solution.

Best,

felix

LFS will let you access an Android device’s public storage if you can guess the path. From there you could copy it to one of the sandbox directories to access from your app. There is no public storage for iOS, only the sandbox.

We do not have an API call to guess the path. While it would seem like it’s a trivial thing to do, it’s not or we would have implemented it.

You may want to consider a server based solution. Now if you’re trying to move files between two apps you’ve written then on iOS, the iCloud plugin supports syncing files between the same apps, or the same suite of apps.

Rob

Hello Rob,

thanks again for your reply.

I dont think it would be trivial to guess a filepath, especially on android.

Actually, thinking a bit more about it, my solution would have made it necessary that the user knows how to copy files to the phone and on iPhone it seems not possible at all…

So I will go the server based solution. (And create a user/password system and maybe even have to make it payed, as I now have additional costs :/)

Best,

Felix

You have access to three writable directories on iOS and two on Android:

system.DocumentsDirectory

system.TemporaryDirectory

system.CachesDirectory (points to system.TemporaryDirectory on Android)

The Documents directory is used to store permanent files. These will be backed up to iCloud on iOS unless you explicitly say not to. Apple does not want large amounts of data being backed up, so any big databases should be flagged to avoid backup.

CachesDirectory is where Apple wants any downloadable files to be downloaded. They can be replaced so if they get deleted, they can be recreated. TemporaryDirectory is for stuff that can be freely deleted.

We have a module called LFS (Lua File System) that you can use to get a list of files in these three folders (and any subfolders you make). You can use this to present a list of files to the users perhaps in a widget.newTableView().

Rob

Hello Rob, and thanks for you answer.

I ment something different, I think. I would need some place where I can copy data to (from outside the app), so that I can access it from within my app.

If these three are the only places where I have access to, I think I will have to create a server based solution.

Best,

felix

LFS will let you access an Android device’s public storage if you can guess the path. From there you could copy it to one of the sandbox directories to access from your app. There is no public storage for iOS, only the sandbox.

We do not have an API call to guess the path. While it would seem like it’s a trivial thing to do, it’s not or we would have implemented it.

You may want to consider a server based solution. Now if you’re trying to move files between two apps you’ve written then on iOS, the iCloud plugin supports syncing files between the same apps, or the same suite of apps.

Rob

Hello Rob,

thanks again for your reply.

I dont think it would be trivial to guess a filepath, especially on android.

Actually, thinking a bit more about it, my solution would have made it necessary that the user knows how to copy files to the phone and on iPhone it seems not possible at all…

So I will go the server based solution. (And create a user/password system and maybe even have to make it payed, as I now have additional costs :/)

Best,

Felix