Writing to external SD card in Android 5.0 and above


(Felix Ableitner) #2

Afaik, this access must go through Storage Access Framework.

The problem with that is it uses special URIs to access files, and golang does not support that (at least that’s what @calmh said a few months ago). Maybe support for this will come when there is full Android support?


(Alistair Cunningham) #3

If it doesn’t exist, perhaps I should post a bounty to encourage creation of it?


(Felix Ableitner) #4

The first step would be to open an issue at golang, and see where it goes from there.


(Alistair Cunningham) #5

Thank you. Would you have any pointers to where I can do this?


(Felix Ableitner) #6

Here


(Alistair Cunningham) #7

I’ve gone ahead and posted a bounty for this:


(Felix Ableitner) #8

I went ahead and opened an issue at golang. Let’s see where that goes.


(davebytes) #9

A colleague just pointed me at this issue. What’s the problem exactly? I see in the code that the manifest has: It also needs the READ_* permission likely. That should give it full access to external storage. Storage Access Framework is a completely different system for interacting with user documents across apps, has nothing specifically to do with write access to sdcard.

And you’ve always needed that permission to read/write sdcard without root. Old apps didn’t have it. The change in KK is that you can now read/write to your private data folder on sdcard WITHOUT needing the permission – you only need it if you want to touch outside your private data.

So is the real problem that syncthing doesn’t USE external storage (sounds confusing, but it only has the WRITE permission), doesn’t expose it to the user as a target, or is there simply a bug under the hood somewhere…

Hope that helps!


(Felix Ableitner) #10

Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission.

The problem is described here. tl;dr you can only write to some folders now (unless a custom rom changes this)


#11

Will rooting the device override this lunacy?


(Felix Ableitner) #12

There will be an option to run Syncthing as root in 0.6.2 :wink:


#13

Nice. Thanks.


(Alistair Cunningham) #14

Is anyone interested in working on this?


#15

I’ve upated my Z3 (not rooted) to Marshmallow, formatted the SD card as ext4 and it’s now seen as internal storage. Syncthing can now read and write from the SD card with no restrictions.


(kisolre) #16

Formatted it how?


#17

Found this steps with a quick seach on google:

Go to “settings” -> “Storage & USB” -> “External SD Card” and select “Erase & Format”. There you should be able to select “use as internel storage”.

I don’t have an Android 6.0 device with SD-Card, so I did not test this.


#18

Can’t remember now as it came up when i flashed Marshmallow. But I’m sure it was under Settings > Storage & USB


#19
Hi everyone! 
I think i solved problem.
Here what you need:
1.Root
2. Xposed framework
3. HandleExternalStorage module for Xposed
Install all this, and THEN enable root in syncthing.

(Jeroen Meulenaar) #20

The problem with that is it uses special URIs to access files, and golang does not support that

Would it be possible to workaround this by shipping a small part of code (or even a separate app) written in e.g. Java (?) that handles storing of files? (I don’t know anything about programming for Android).


(Harald Eilertsen) #21

So in short this is an issue because we’re still stuck with FAT? I really wish the world would progress sometimes…

Anyways, I was able to create a folder under /storage/sdcard1/Android/data/com.nutomic.syncthingandroid/files that Syncthing accepts and syncs with. As long as that works I’m fine with it.

Thanks for a great app!