Writing to external SD card in Android 5.0 and above

I’m using that feature and all my apps are still getting installed on the internal storage, not the sd card.

1 Like

Good to know, thanks. I never had the chance to test it, just read that they get installed to the storage with the most free space available by default.

Anyway, as long as the manufactures officially don’t support “adoptable storage”, getting support for the storage framework into Go seems to be the only option that will work everywhere.

I got a android 5.1 device, and i thought they fix the write to ext sd, but when I set it up, some of the folders cannot be sync, ie. /mnt/extsdcard/Download. but some other ones were able.

There is no root option for my devices, so I can’t get it to work.

Google added a possibility for Apps to access the ext SD via a new API. But GO (Google’s programming language) doesn’t support that new API (yet).

If you only want to sync from your phone to antoher device, than adding the folder and manually creating an empty file .stfolderinside that folder (with an App that supports the new API) should enable Syncthing to sync that folder.

Thanks, I was able to add that to the syncthing, but everything in the folder has a “permission denied” status and so far nothing gets synced

Update: I was able to copy the files from the other devices along with the .stfolder. syncthing can scan the files, but I am getting permission denied on all the files I need to sync.

Please re-read wweich’s reply. You can only synchronize files from your phone using this solution, not to it (aka Master folder).

Shamelessly quoting myself:

Is the adoptable storage only available in Marshmallow?

I understand the third one, I can only use it as a master folder, it can upload, but can’t download from syncthing.

Could you explain what is the second one? Do I have to put the folder that I want to sync in inside the app "…in my ext sd?

Yes.

When you create a folder in syncthing-android, you should see two entries in the folder picker list ending with /Android/data/com.nutomic.syncthingandroid/files. One points to a folder on the internal storage and the other one is a folder on the sd card. When you choose the sd card, you can create new folders there which are writable.

This solution, however, only works when the folder location doesn’t matter. You cannot use it to share data that was written to the sd card somewhere else by another app, like the DCIM folder.

1 Like

Hi, I want to ask what is the status of this problem? Is it solved? Or is there some recommended workaround?

I will be buying galaxy note 7, and synchronising content of whole SD card if essential part of my workflow. I have apps on android 6 that can read/write to whole sd card (Total Commander) so it is technically possible, right? I am willing to root the phone if it would help, but the informations here and on github seems to be a bit confusing… samsung doesn’t support the merged storage… so how can I sync the whole SD card please? Thanks.

You can only sync it read only / master by creating the .stfolder file yourself. It is still not possible to write to external SD, as (afaik) GO still does not support the File Access API needed in current Android versions (which e.g. Total Commander uses).

You can also use the merged storage feature, or whatever that is called.

samsung doesn’t support the merged storage


Also, I never found “merged” storage, but only a feature which replaces the internal storage with the external SD card. With that, Total Commander will only see the external SD Card and Pictures and the Android Data folder is always on teh external SD card. But apps can still save data on the internal storage and some apps will let you choose where to store the offline files.

Unfortunately Samsung doesnt support the merged storage on their phones.

This a major issue, is there really no way how to solve it? Is the GO android framework taking this seriously?

1 Like

It’s not possible, see the links in the FAQ.

Also, it works of you have root, and run Syncthing as rooted.

What I struggle to understand is why after two years after you opened the issue on golang github page, this is still not solved. Java apps can have read/write access to whole SD card, so it is technically possible. This cripples the whole Android-GO development and makes it hard to take GO as serious language/framework for Android development… or am I missing something?

The idea to write the problematic part in Java, was discused on the issue page, but without any conclusion… could this be the solution? How hard would it be…?

2 Likes

Go is taken seriously on Android, but nobody who cares enough about this specific problem, so nobody has invested any time into this. I guess the primary focus is things such as games and EGL apps which can get away without sd card access.

Writing the problematic part java is a lot of work, first, because you’d have to implement a fair amount of abstractions in syncthing to support some sort of bridge into java for a filesystem, as for now we use filesystem access provided by the stdlib, which sadly is not interface based so you’d end up having to reimplement a fair share of standard library for walking, globbing etc, etc.

Again, this is something it seems nobody is interested in investing time in, just because it’s a very very timeconsuming hack.

Since currently there is no way to provide external storage to the native binary, it won’t work unless Syncthing binary adds an API for providing external data, or most of Syncthing’s functionality is re-developed in Java. I don’t think this going to happen soon, so the more realistic scenario is that sooner or later Android Document Provider API is somehow supported in Go.

I don’t know how you could use Java for that. Youd’d have to call Java from Go, and I don’t think that is possible. Afaik the solution is using the NDK from Go.

Edit: Wtf everyone commented at the same time :smiley:

I did this on a Sony Xperia Z2 running Android 6.01, that is not rooted, to sync the pictures on the sdcard. I copied the file .stfolder from /storage/cardid/Android/data/com.nutomic.syncthingandroid/files/ to /storage/cardid/DCIM/Camera. Added a new folder to sync and selected the /storage/cardid/DCIM/Camera folder and it’s syncing right now to the server.