We're using Xamarin and C# to convert our application from a 9590 to the TC75 and we're having issues accessing the external SD card.
When I run: Android.App.Application.Context.GetExternalFilesDirs( null );
Samsung S5 returns
files[0] == /storage/emulated/0/files/
files[1] == /storage/extSdCard/files/
TC70 returns
files[0] == /storage/sdcard0/files/
files[1] == /storage/sdcard1/files/
TC75 returns
files[0] == /storage/emulated/0/files
files[1] == /storage/sdcard0/files
When we run: Android.OS.Environment.ExternalStorageDirectory.AbsolutePath and there is an SD card in the device:
Path TC70 returns
/storage/sdcard0/ --> and the application writes to the SD card
Path TC75 returns
/storage/emulated/0/ --> and the application writes to the internal memory
Path Samsung returns
/storage/emulated/0/ --> and the application writes to the internal memory
We want to store our database on the SD card, as we currently do on the 9590.
We can't use the first method, as this adds too much risk to supporting the application in the field, because this forces us to send out a new database every time the app is updated and if someone from the support team tries to re-install the app without making a copy of the database first, data will be lost.
The second process only works on the TC70. When there is an SD card in the device, the call returns the actual SD card, not the internal storage. The TC75 responds the same way the Samsung device does, in that there is no reliable way to determine if there is an SD installed and then no reliable way to access the card. If we just try and manually put the path in, then the files are marked as read only and cannot be updated.
1 Replies
Hi Tom,
you can usually use environment variable to get the External SDCard path.
Here you can find a description of the details:
http://pietromaggi.com/blog/finding-the-sdcard-path-on-android-devices/
and here the linked sample, is in Java but should be straightforward to convert it to C# in Xamarin:
https://github.com/pfmaggi/GetDeviceInfo
This was written before the final release of TC70, however the informations should be still valid.
Regarding TC75, we're working to provide a consistent behaviour.
Best regards
~Pietro