In my android application I have configured a periodic syncing using sync adapter, and its working fine except if the android storage space is running out.If i deleted some files and free up space then sync will start to work.Actually I am just syncing data from my device to the remote server,so there is no need for extra space in device while syncing.So why does the android sync adapter demand some space to work.What I noticed is the sync adapter won't work even if there is a 2% free memory is in the device.Similary I found that the gmail application in android device also won't work if 98 percentage of device memory is used.Gmail will show a couldn't sync message and will not sync and receive any message if device memory is full.So is there any way to start the sync adapter if the memory is full? If not then how can i notify my application users about this fact?
-
Could either be a intentional limitation to ensure syncing doesn't steal too many resources and destabilize the OS, or syncing could actually (for whatever reason) require caching to the card while the sync happens. When you're low on space, Android gives you a message that says "some things may not work", so I'm going to go with the former. – Carcigenicate Jan 30 '17 at 12:32
-
Ok.So how can i notify my app users that syncing will not performed because of this reason within my app?? – KJEjava48 Jan 30 '17 at 12:34
-
@Carcigenicate I have googled about this limitation and its not mentioning in any of the links based on sync adapter – KJEjava48 Jan 30 '17 at 12:38
-
Put a listener on the "storage full" event, and send a notification when it's triggered. – Carcigenicate Jan 30 '17 at 12:40
-
@Carcigenicate How can i do so in my app??Can u please show/refer some example – KJEjava48 Jan 30 '17 at 12:42
-
I don't do Android dev, so I've never done it. I know thats how it works though. Search through the Android API to find how to add event listeners. – Carcigenicate Jan 30 '17 at 12:47
1 Answers
This is standard AOSP/Android behaviour.
The SyncManager listens to the Intent.ACTION_DEVICE_STORAGE_LOW intent that is sent when the device is low on storage and cancels any active syncs
It also listens to the Intent.ACTION_DEVICE_STORAGE_OK intent in order to find out that the storage is back to normal and reschedules the syncs
It does this probably because it is backed up by the SyncStorageEngine that stores various information in XML files
Though this answer is late, if you want to notify your users, On Android Oreo and below you can listen to the same broadcasts and notify them. From Android Oreo it gets a bit more tricky as the recommendation is to use the Context.getCacheDir() in order to manage your cache space. Refer to this answer for more details

- 1,386
- 1
- 16
- 26
-
too late to answer, but I appreciate it bcos it will help others if this is the way to solve the issue.Thanks....... – KJEjava48 Sep 25 '20 at 06:17