On iOS, there's the FILES app, and if your app writes anything to it, it'll propagate to all devices.
I notice in the Google Files app, there's a "documents" folder. If I give the user the option to save data into that folder, will it automatically sync between their devices in the same was iOS does? I'm looking for the simplest way to give the user the option to save their data somewhere that will sync to all their devices.
The closest thing is autobackup. This is meant for installing an app on a device, or uninstalling and later reinstalling. It isn't really meant for syncing, as figuring out conflicts without being the app developer would be nearly impossible. Cache coherency is a hard problem. THe docs for Google's Auto Backup feature are at https://developer.android.com/guide/topics/data/autobackup
Anything stored in the app's internal or external storage will be saved, as well as any dbs in the default db directory and any shared preference files. Files in the cache directories are not backed up. There is a 25 MB limit per app for backup. If you are over 25 MB, your app will be notified but no backups will be made until you're under 25 MB again.
Related
My app creates large files of my own format. We used to save those on device memory but from sdk level 30 we can't access them anymore (it is too slow and complicated to use DocumentFiles).
Is there a way to store files in scoped storage that are not media files, that doesn't increase app memory and bog it down?
And I am also worried about files being deleted when a user uninstalls the app.
What is the best way to do this?
Edit: We used to store it on a folder on the phone memory that is accessible by the user via file browser. On Android 11 we can't do that so the files would have to move to scoped storage i.e. Android/data//files
Is there another storage location that an app can access on Android 11 that won't be deleted after app uninstall?
I've been using a homemade greasemonkey scripts for ages on my laptop Firefox. It includes storing data with GM.setValue.
Now I just bought an Android tablet, and would like to be able to use this script and update the values, whereas I'm using the laptop or the tablet.
Hoped that Firefox Sync would handle that, but not even the scripts are synced.
I thought of synchronizing the script dans db files (Google drive, dropbox, whatever), but I realized that since the v4, the db that used to be in gm_scripts is gone, and I have no idea where Greasemonkey stores either the scripts or their associated database now.
I'm looking for anything that might make it work.
1) Is there a way to handle that with Firefox Sync ?
2) Would an alternative (Tampermonkey, Violentmonkey, ?) handle that better ?
3) Where can I find the scripts/database in the new Greasemonkey system ?
4) Could I synchronize them via Google drive ? (There seem to be some hacks to sync a file between machines)
5) Would there be a simple, free alternative that would allow me to synchronize a very small file between machines ?
===============================================
Update on this:
I tried TamperMonkey instead, it has a sync feature but even if it seems ok on different laptops or my phone, the syncing is random at best on the tablet.
Also realized that only scripts are synced, and not their data. The script almost never changes, but the data is updated several times a day, so not really a solution anyway.
Data doesn't exist anymore in a readable file format, so no luck either on syncing the data file externally.
TamperMonkey has also an import/export feature, this does take the data into account. So the best I can do for now is thinking about exporting then importing every time I switch device. Not ideal so still in search of a better solution.
Conclusion:
1-2) I switched to TamperMonkey where I could easily up/download scripts from Google Drive (or other).
3-4-5) New browser extensions architecture means that you basically can't access the data on file system
The only solution is to store/retrieve data elsewhere, not with the GM methods. I stored mine in an airtable base, because it offers a pretty easy to use API that can be called from user scripts.
storage.sync
Represents the sync storage area. Items in sync storage are synced by
the browser, and are available across all instances of that browser
that the user is logged into (e.g. via Firefox sync, or a Google
account), across different devices.
There are limitations with sync.
Sync requires login
Up to 100kb can be synced and more than that fails
Storage sync usually syncs the entire extension storage and in case of user-script managers, they are often larger than 100kb as they include the user-scripts as well
Data is stored elsewhere (not on your computer) which can have security/privacy concerns
Storage read/write requires internet access and longer times due to remote data storage
Extension must have the sync option
1) Is there a way to handle that with Firefox Sync ?
Yes but depends on aforementioned. While Firefox sync doesn't appear to have the 100kb limit, syncing the entire Firefox takes longer (How do I set up Sync on my computer?).
2) Would an alternative (Tampermonkey, Violentmonkey, ?) handle that better ?
Greasemonkey: No sync feature
Tampermonkey: Sync to Dropbox, Google Drive, or a WebDAV service
Violentmonkey: Sync to Dropbox, OneDrive, Google Drive, or a WebDAV service
Firemonkey: No sync feature
TM/VM 3rd party storage sync allows storage of more than 100KB. However, using 3rd party storage allows 3rd party tracking which is a privacy consideration. The storage read/write operation is also a lot slower.
3) Where can I find the scripts/database in the new Greasemonkey system ?
Since Firefox 57, extensions can not save files to the HD and the only storage area is the extension storage which is not accessible as before.
4) Could I synchronize them via Google drive ? (There seem to be some hacks to sync a file between machines)
Refer to above
5) Would there be a simple, free alternative that would allow me to synchronize a very small file between machines ?
That depends on the set-up and how often data is changed.
For example, if data is not often changed, especially if the data privacy is imperative, there is the backup export/import option (script + data). Therefore, the extension data can be saved to a USB flash drive and loaded anywhere (suitable for shared environment).
I'm developing application that is targeted for API 18. Application download data by Bluetooth and GSM and stores data on internal sdcard (usually \emulated\sdcard - readed by Environment.getExternalStorageDirectory()).
Till this time everything works fine - files and folders are correctly saved.
Today i've faced very strange behaviour:
1) Started the app, and it works for over an hour and store data files.
2) After that, i've closed app and want to download data to the computer.
Before plugin USB, I've used Android file explorer software to check stored data.
I was shocked - new folder (any new data) was gone!
It's like system removes or hide all files and data created in last app session.
Remarks: application don't have procedures for deletion folder or files. Also it works good on previous versions of Android (mostly 4.X and 5.X).
It's very strange because app has warning mechanism when save isn't possible and that warnings wasn't displayed. So I think, write was allowed by system, but data isn't visible at this moment.
Another stranger thing is that application can't write any file in internal storage from this moment (and the warnings are displayed as should in this case).
It looks like Android Marshmallow "decides" in particular moment - your new data won't be available anymore, and your app won't write to internal card.
I've checked app permissions in system - OK.
Any ideas, why this happens? How to deal with it?
You may refer to these guides for managing permissions during runtime: http://www.howtogeek.com/230683/how-to-manage-app-permissions-on-android-6.0/
https://developer.android.com/training/permissions/requesting.html
I'm currently working on an app which downloads a zip file and extracts a bunch of tiny mp3 files into external storage. The zip file is about 2.5 meg.
I'm wondering if it would be a better idea to include the zip file in app resources, and then copy and extract it to the file system. This would prevent the headaches involved in something like a lost connection during the zip file download. I noticed some missing mp3s, and when I checked the zip file, the last 20 or so weren't it it. So, it looks like the system can successfully (an unfortunately) extract from an incomplete zip file.
The downside including the zip file in app resources is obviously that it increases the size of the app by 2.5 meg. I've specified "prefer external storage" in the manifest. This isn't supported before release 2.2, i.e. level 8, so I'm already excluding those phones, which probably is 20 or 30 percent of the total android phones. But I'm not entirely sure if that guarantees the app will be installed on the SD card.
It could be worth including the zip file in the app just to avoid the potential hassles in handling the download of the zip file; but if the size of the app makes it unappealing, then that's kind of a drawback - especially if the "prefer external" doesn't work on some devices.
Which is the better option? Ideas are welcome.
One of the highest selling Android Games, Gun Bros, does what you are thinking about: small app, that downloads the content on demand. This allows them to also serve ads while the content is downloading. In addition, by downloading the content you can make use of compression over the network thus reducing the total amount of data a user will actually have to use to get the whole application. I think in the end it is a personal preference, but I would lean towards downloading over the network.
Given the fact that there are some apps/games out in Android market which are in the 40+ MB range a 2 MB additional download doesn't seem that much to me. Anyway your users have to download it one way or another. Either in the apk or as a separate zip file.
Now Android market allows you to post updates to your application so your users can get new content through there.
Regarding prefer external storage, it is just that - a preference. If external storage is not available or a user is installing it on a 2.1 phone, then it will install the application to internal storage, as long as your applications minimum SDK level is 7 or lower.
But there are other applications I can think off that download content from sites, things like scripting for android (SL4A). If you want to update your game content that way, I would recommend creating a mechanism whereby your application can first discover the size of the download, then do the download. And once the download completes, verify the size against the size it should be. If the two don't match, then run the download again or something like that.
I'd recommend just including it in the apk file. Many apps on the market are like 5-10 MB, and games can be even bigger (I've seen games range anywhere from 1 MB to 40 MB), so adding 2,5 MB to your app shouldn't really be a problem, even if they don't support installing to sd-cards.
My phone for example have 2.1 and therefor can't install to the sd-card and I've so far never run out of space even after installing a bunch of 2-5 MB apps.
And no "prefer external storage" does not guarantee that it's installed on the sd-card, if the user doesn't have an sd-card for example, or if they choose themselves to move it to the internal storage.
Point is, adding 2,5 MB to your apk isn't anything anyone will really notice or care about, and you shouldn't need to either.
i'm writing an application that needs to store some data,and picture. For example place's information. this information don't need to change very often. and
I have seen that databases are
stored under /data/data/package_name/databases
I decided to store my data under /data/data/package_name/files.
With the emulator i can see all these files (databases)
under the proposed directories but moving the application on a real
device and installing a file system browser i cannot see any file
under /data. i know that there are some security constrain in (not-rooted) device. However, are there any suggestion about the solution.. where can i store these data and how? because i'm quite new to android. Thanks so much for your help.
The reason you can't see it on the device is basically just as you said; the device isn't rooted, so other apps don't have access to the /data folder.
This is okay though, because you can still store your files there. Your app has access to anything under /data/data/package_name/, you just won't be able to see it in a file browser unless you root. This is normally a good thing, to keep average users from mucking around with your databases/files.
Read up more on storage methods here.