kiwix-android icon indicating copy to clipboard operation
kiwix-android copied to clipboard

Custom apps should be moveable to the external SD card

Open kelson42 opened this issue 7 years ago • 17 comments

From @kelson42 on November 29, 2016 11:33

Kiwix releases pretty big custom apps (~1GB). Google plays allows only to downlaod the app on the main memory. Android allows only to move the app (and not any companion files) to the external SD card.

This is a problem because most of the people do not have a lot of free space on the main storage or do not want to keep it there.

The solution is not clear to me, but IMO we should provide - at least - a feature to move the whole app (main APK + companion file) to the external SD card. Hope this is feasible at all!

Copied from original issue: kiwix/kiwix#374

kelson42 avatar Mar 18 '17 12:03 kelson42

From @mhutti1 on November 30, 2016 0:18

@kelson42 Well I guess its theoretically possible. We have write access to the .obb so we should just be able to provide an interface to copy it to another storage directory. Might be fiddly to implement correctly though and Google play likely wouldn't like it so might require a very hacky solution.

kelson42 avatar Mar 18 '17 12:03 kelson42

  • APK: Android itself has a tool to "migrate" an app to the ext SD card (at least on my Samsung device) and I believe to remember that many apps provide this kind of feature. So maybe the primitive is available in the Android SDK and we can use it to let Kiwix migrate itself.
  • OBB: Might be interesting to have a proof of concept (moving obb somewhere, and see how Android behave - update, uninstall, etc..).

Both might be "spike kind" CGI tasks maybe.

kelson42 avatar Mar 18 '17 12:03 kelson42

Duplicate of #8

kelson42 avatar Mar 18 '17 12:03 kelson42

From @mhutti1 on December 1, 2016 21:44

@kelson42 I don't think we can achieve number one based on the nature of android. Number 2 sounds feasible however and might be suitable as a GCI task to create a proof of concept / fail and produce well written documentation on why it is not feasible.

kelson42 avatar Mar 18 '17 12:03 kelson42

@mhutti1 (1) OK, how work apps allowing to move apps to the SD card? Or does the problem is that the app can not move itself? (2) Sounds good.

kelson42 avatar Mar 18 '17 12:03 kelson42

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Jun 26 '19 07:06 stale[bot]

I am having great trouble installing kiwix on an sd card on any of my devices/emulators. My Samsung tablet won't format an sd card as internal, my budget device will but fails with "not enough space" despite having 100GB+ free. I have tried altering android:installLocation to preferExternal to no avail.

I have seen a few comments saying that kiwix does not perform well when on the sd card so it should be feasible though very much warranting investigation.

I think copying the obb expansion files is fraught with danger and should be avoided, link

Do not delete or rename the .obb expansion file (unless you're performing an update). Doing so will cause Google Play (or your app itself) to repeatedly download the expansion file.

This situation is pretty easily avoided with the "just download it ourselves" solution.

macgills avatar Oct 25 '19 13:10 macgills

@macgills Would that be true to say that moving an app to an external SD card is not an official/std Android feature?

kelson42 avatar Nov 06 '19 14:11 kelson42

It is an official feature just sd cards in general are poorly supported, the Pixels for example don't have sd card slots. If some other developer can get this installed on an sd card it would be beneficial, I haven't tried in the intervening 12 days

macgills avatar Nov 06 '19 15:11 macgills

@macgills Ok, if not official, descoped

kelson42 avatar Nov 07 '19 01:11 kelson42

It is official, there is a manifest property installLocation that accepts 3 values ["auto" | "internalOnly" | "preferExternal"] and we currently have it set to auto ie no preference but it can be installed to an sd card. It just seems to work a bit funky, I can experiment more at a later date but I was just doing this as to occupy my time while awaiting decisions on custom app processes

macgills avatar Nov 07 '19 09:11 macgills

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

stale[bot] avatar Jan 06 '20 09:01 stale[bot]

To me, depends on #56

kelson42 avatar Sep 01 '23 07:09 kelson42

@MohitMaliFtechiz @gouri-panda I woukd like your feedback on this. Is that meanwhile doable? What would be the conditions?

kelson42 avatar Nov 16 '23 20:11 kelson42

@kelson42 We have to ask for external storage permission in run time. Since we're doing an install-time download, we can't directly store it in external storage. If we wanna move later then I believe we can achieve this. We should also consider these factors 1. Do we have permission to external storage? 2. Do we have an external slot for The Pixel phone doesn't have slot 3. Do we have low storage issue? I don't know about the performance issue in large files like you've discussed above but I think it depends on the external slot card type. Generally, we do have fast built-in memory card compared to an external sd card. @MohitMaliFtechiz What do you think? Are there any limitations we have?

gouri-panda avatar Nov 16 '23 21:11 gouri-panda

we can't directly store it in external storage.

If we change installLocation to preferExternal than the system will automatically install the application on the external if possible see more details here https://developer.android.com/guide/topics/data/install-location.

If we wanna move later then I believe we can achieve this.

@gouri-panda We can achieve this with the existing code, but we can not do it programmatically at least on Android 12, below I have not tested it yet.

We should also consider these factors 1. Do we have permission to external storage? 2. Do we have an external slot for The Pixel phone doesn't have slot 3. Do we have a low storage issue?

It will automatically handled by the OS as mentioned in the official docs https://developer.android.com/guide/topics/data/install-location.

I have tested it on the Android 12 device, for achieving this we need user interactions. The user needs to enable to Force allow apps on external option in developers setting (might be different according to the devices and might be by default enabled in lower devices).

https://github.com/kiwix/kiwix-android/assets/34593983/ecd78a7d-1288-4a79-8af6-27b7a7652d88

Google pixel 7a also has this setting so might be it is for moving apps on USB-OTG.

1700464678214

I don't know about the performance issue in large files like you've discussed above

To confirm this we need to test it with large file.

Important note For testing the moving functionality please create a signed apk and install it on the device, the debug version will always show not enough storage.

MohitMaliFtechiz avatar Nov 20 '23 07:11 MohitMaliFtechiz

@MohitMaliFtechiz How much work is needed here? Should we try to implement this as "quick win"?

kelson42 avatar Jan 30 '24 18:01 kelson42

@kelson42 As I showed above we can not do it programmatically if the user wants to move the application from internal to external storage. Hence, we need the user interaction for this. We can add the steps in the custom app on how users can move the application to external storage. The system will automatically decide the moving process according to the device, Whether it has enough storage or not, whether the application supports this feature or not etc. As shown in the above comment Android 12 this feature is working fine, but I have tried it with multiple devices to properly check the feature compatibility.

On the Android 7 emulator, this feature is not available also documented in official docs https://developer.android.com/guide/topics/data/install-location#Compatiblity.

Screenshot from 2024-02-19 15-15-41

Here are some useful links:-

  1. https://www.quora.com/How-do-I-transfer-apps-in-Android-to-an-SD-card-external
  2. A Google expert describes the limitation of moving apps to SD card https://support.google.com/googleplay/thread/218191339/how-to-automatically-download-all-apps-to-sd-card?hl=en#:~:text=Go%20into%20your%20phone's%20settings,app%20you%20want%20to%20move.

So here we already have the android:installLocation="auto" set in the manifest which makes our application moveable. Here we can show the steps in our custom apps that how they can move application into SD card. @kelson42 Is it okay for you?

MohitMaliFtechiz avatar Feb 19 '24 11:02 MohitMaliFtechiz

@MohitMaliFtechiz Thank you for the extended documentation and explanation of the case. If not possible, i consider there is nothing more we can do here and will close the issue.

kelson42 avatar Mar 11 '24 06:03 kelson42