You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "nookasaisri88 (via GitHub)" <gi...@apache.org> on 2024/09/25 15:50:21 UTC
[D] Persistent storage [cordova]
GitHub user nookasaisri88 created a discussion: Persistent storage
On launch of our cordova app in android, it asks user to enter some url to get redirected, and we store it in localstorage. When we clear the appstorage the url gets cleared from localstorage. We want to store it in some persistent storage so that , even if we clear app storage we should be able to get url and use it later . I tried multiple ways with cordova file plugin , native storage, sqllite.. etc. , none of them seems to work. Facing issues with permissions in API>=30 .
Appreciate any ideas how to get this work done?
GitHub link: https://github.com/apache/cordova/discussions/497
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [D] Persistent storage [cordova]
Posted by "nookasaisri88 (via GitHub)" <gi...@apache.org>.
GitHub user nookasaisri88 added a comment to the discussion: Persistent storage
Thank you,
I have one more doubt. I'm working on android 10 - sdk 29, created an emulator, I'm unable to access storage/emulated in file explorer.

I would like to create files on this storage manually and I want app to read from it. I was able to do so in android 11,12, and 13 but not in 10. I'm using cordova10.1.2. Even I set :requestLegacyExternalStorage to true in android manifest file in application tag.
GitHub link: https://github.com/apache/cordova/discussions/497#discussioncomment-10760372
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [D] Persistent storage [cordova]
Posted by "nookasaisri88 (via GitHub)" <gi...@apache.org>.
GitHub user nookasaisri88 edited a comment on the discussion: Persistent storage
Thank you,
I have one more doubt. I'm working on android 10 - sdk 29, created an emulator, I'm unable to access storage/emulated in file explorer.

I would like to create files on this storage manually and I want app to read from it. I was able to do so in android 11,12, and 13 but not in 10. I'm using cordova10.1.2. Even I set :requestLegacyExternalStorage to true in android manifest file in application tag.
Minsdkversion : 21
Targetsdkversion: 31
GitHub link: https://github.com/apache/cordova/discussions/497#discussioncomment-10760372
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [D] Persistent storage [cordova]
Posted by "smodatos (via GitHub)" <gi...@apache.org>.
GitHub user smodatos added a comment to the discussion: Persistent storage
You can create a text-file in the device's Documents folder with the **fileWriter** of the **Cordova File Plugin** (don't forget to delete an eventually existing file with the same name before - fileEntry.remove is your friend ...).
From the Documents folder you (and everybody else) can read later this file with the **fileReader** of the **Cordova File Plugin.**
Notes:
- Don't store sensible data there (everybody could read them)
- Encrypt data before writing (for the case that someone else reads your file)
- Don't mess up the user's Documents folder with thousands of files which even you don't remember that they exist
As an **alternative** the so far free **Cordova Cloud Settings Plugin** might serve.
But as for it stays in the 'cloud', if the 'cloud-owner' (Android's Data Backup service or iCloud for iOS), some day decides to change politics, this might affect you.
GitHub link: https://github.com/apache/cordova/discussions/497#discussioncomment-11204756
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [D] Persistent storage [cordova]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
GitHub user breautek added a comment to the discussion: Persistent storage
The user can clear **ALL** local storage.
The browser's storage mechanisms (cookies, local storage, indexedDB) are all stored in the app's data directory. The file plugin exposes the ability to store files directory into the app's data directory, as well as some other directories.
When the user uninstalls the app, or clears app storage, the OS will clear the app's data directories which includes all that is mentioned above.
Short of controlling the data on a server and having the user to log into an account to relate that data to the user, it is impossible to guarantee persistent storage. Other options that doesn't involve a server:
1. Is to use a media store plugin to store files on the user's "external" filesystem inside the documents container.
Other apps may be able to read these files so it's not suitable if storing anything sensitive. The user can still delete the file, but as long as you don't use an app-specific external storage, the files should be retained (90% sure...).
Apache's file plugin has limited support for external storage since Android's SAF framework. It's not suitable for writing documents to external storage. Therefore a third-party plugin that interfaces with the native MediaStore APIs is required.
2. Use a plugin to integrate with user's cloud storage such as google drive. Naturally the user can still delete the data, and other apps may also be able to read that data. So it faces similar issues as using the external filesystem partition. But I don't believe the data is cleared on app uninstalls or explicit clear app storage requests since it's external to the app's data directories.
Note that some jurisdictions, by law, you must provide some sort of mechanism to allow users to delete their data.
GitHub link: https://github.com/apache/cordova/discussions/497#discussioncomment-10753507
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
Re: [D] Persistent storage [cordova]
Posted by "breautek (via GitHub)" <gi...@apache.org>.
GitHub user breautek added a comment to the discussion: Persistent storage
API 29 is kinda special. I am kinda surprised that it reports a permission denied error though still, but I'll explain what is probably occurring.
First, `requestLegacyExternalStorage` is only honoured if you're targeting API 29 or lower. Starting with API 30, it is forcefully enabled and that setting is ignored. This means `requestLegacyExternalStorage` is not usable if you plan on deploying to the Google Play store. The flag was introduced when SAF (Scoped Access Framework) was introduced in API 29. But at that time you could opt out of SAF and get the old API 28 and earlier behaviour on API 29 to give developers a good amount of time to test and make changes to their applications. It was always documented that the setting will be ignored in a future target SDK, which that occurred on API 30+.
Under SAF, you're expected to use the [MediaStore](https://developer.android.com/reference/android/provider/MediaStore) APIs to access the external filesystem (that is the `/storage/emulated/...` path and/or `/sdcard/...` path) and Android disabled access to these paths with the `File` APIs (which is why `cordova-plugin-file` uses). Specifically on API 29, using the Java File APIs to access the external storage is not possible.
In API 30, they introduced something called [FUSE](https://source.android.com/docs/core/storage/scoped#using-scoped-storage-with-fuse) which enabled file APIs once again, although with several limitations.
Because API 29 devices lacks FUSE, it might be why you're unable to list or explore the contents of `/storage/emulated/...` even in the file explorer. If you're using a `Google Play` image for your emulator, you might want to try the AOSP image instead which would have more relaxed security policies allowing you to be able to test easier. If that does work, it does indicate the ability to explore the content on retail devices will be limited.
GitHub link: https://github.com/apache/cordova/discussions/497#discussioncomment-10761743
----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org