My flutter app provides some content (mostly text and graphics, like blog posts, or news) to its users. These contents need to be updated daily. So there will be new texts, images, maybe even videos. Now, the app would be used even when offline, so all the updated contents should be stored somewhere to be accessed later.
Right now, I'm using a SQLite DB to store texts
The images are stored in the Assets folder of the app.
The nature of the program is such that the users won't want to give the app any SD-Card access permission.
So my question is, how can I update the content without updating the whole app or using any SDcard permissions?
Is it possible to write code that downloads the new content and saves them directly in the Assets folder of the app? Can the app then use the files? without them being referenced in "pubspec.YAML" file?
Can I store all the data (even images and videos which are added daily) in my SQLite DB which is located in phone memory?
What is the standard practice for apps that have this kind of content?
You have to use the storage somehow.
In Android, you don't have to ask for storage permission if you want to save data in internal directory for your app which is storage/emulated/0/Android/data/data/your_package_name/ folder. You can try that.
However it has got a downside, if your app is deleted then all the data will also be deleted.
Related
I have an android app where I embed in assets folder a CSV file about 1MB. This file contains 20.000 records of data and it's for read-only. Until now whenever I need to add/remove some records I publish a new apk with the updated CSV. This happens about once per week and usually, the app has no other changes.
I'm thinking of another way to update the CSV file in the user's device.
One option is the app to download the file from some CDN.
Is it possible through play-store to upload there just the file and somehow to be pushed to the user's devices? I'm not sure if Android App Bundle can be used in my scenario.
You can host the csv file on server. If you find its too hassle to build and manage you custom server, you can use Firebase Storage. And even better and efficient solution would be to parse the file, insert it into in Firebase Realtime Database and when updated, user will only get the update portion
i have developed a android app for farmers. it is a informative app for indian farmer.The users will be sending me the images and video files to me through my app. here i used (integrated) dropbox to receive those files directly to my dropbox space. whatever the image or video taken by the user, it will be stored on a folder in my mobile storage. Here what i want is, i want the folder in my mobile storage to be in sync with the folder in my dropbox.
How can i do this?
there is a app in market called Foldersync which exactly fulfil my requirement. how they are doing it? How can i keep a folder in my mobile storage and a folder in my dropbox to be in Sync?
Note :
i have gone through drop-box api and created a simple app to send files directly to my dropbox space and i know how to download a entire folder from dropbox.
But here my question is unique from that... pls don't answer the above points which i already know..
Please help!
Thank You
You can use the Dropbox API to keep a local client in sync with Dropbox. There are two main pieces to this:
1) Metadata:
Assuming you're using the Core API, the best way to get information about all of the file and folders in an account (or optionally under a specific path) is to use /delta:
https://www.dropbox.com/developers/core/docs#delta
With this, you can get information about everything your app can see, and then easily stay up to date with changes. There are some useful blog posts on using /delta here:
https://blogs.dropbox.com/developers/2013/12/efficiently-enumerating-dropbox-with-delta/
https://blogs.dropbox.com/developers/2013/12/filtering-dropbox-delta-results-by-path/
2) File content:
Using the metadata retrieved from #1, you can download any files you need access to locally using /files (GET):
https://www.dropbox.com/developers/core/docs#files-GET
You can upload locally changed files using /files_put:
https://www.dropbox.com/developers/core/docs#files_put
Or, for larger files, use chunked uploading:
https://www.dropbox.com/developers/core/docs#chunked-upload
https://www.dropbox.com/developers/core/docs#commit-chunked-upload
The main work here will involve programming the logic in your app to correctly receive changes from the server as well as upload local changes, in order to keep everything in sync.
Also, be aware that on mobile devices, bandwidth can be limited and/or expensive, so be careful to not accidentally automatically download a lot of data the user doesn't want or need.
I am writing an app that requires the ability to pull data from a cloud database and store the data locally. I'm using SQLite to store the data when i collect it from the cloud DB, but it's knowing what to do with images.
In the cloud database, I have a URL string pointing to the image. So i now need to be able to grab that image and store it somewhere locally so that i can reference in my code (i need to be able to access it with no internet, so needs to be cached or saved somewhere).
I've done a lot of reading on this but there seems to be some contradiction and dispute in terms of the best way to efficiently store images locally and where. I assume i need to store it as a Bitmap image, but where is considered best for this?
Ideally if the app is deleted, the images should also be deleted. I'm targeting Andorid 4.3 and above only if that makes any difference.
Any pointers appreciated. Thanks.
Store them in the applicatoin package path under the files directory: /data/data/com.your.package.name/files. This directory is removed when your app is uninstalled from the device.
You can access this directory by using:
string filesPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
I'm developing an ebook reader app for Android. The special books for this app are zipped files of some html/css/js/image/... files which are in a server and will be downloaded by the app. Each zipped file may have 1-5 MB and if extracted, a lot more than that.
I was wondering, regarding to android guidelines, where is suitable to
Put the zipped book files?
Put the extracted files when they are being used?
Well, if you actually need to save that data when app finishes, you should use sd-card, since it has more space, but if you only download image one time, just to show it on screen than use internal storage. Also consider your lowest API since that will be phone with least storage, and your app needs to work there as well as on new devices. Either way if you have to make several files while extracting data, use internal storage because it will be faster, and move it later to sd card if you actually need to save it.
I have a simple application that should handle (display, play...) data downloaded by users. I.e. when the user downloads the application (for free), it is empty, or filled just with some sample data, but then the user can download the actual content of their preference (and potentially pay for it via Android billing system). Each item is a folder with an xml file plus several sub-folders (such as audio and images). In the development phase the data are stored in the assets directory.
The payment itself is not a subject of the question at this point. I am actually interested in the following:
where can I store the downloaded data in the phone so that it would be accessible for the application but so it could not be copied manually by the user (for example to another phone). It would be ideal if I could store the downloaded data in the assets directory but I'm afraid once the apk file is generated, assets are "locked" and cannot be easily extended (or can they?) If I store them on the phone's card (or in the built-in memory), they will be accessible by other applications such as media player or galleries, too, won't they?
it would be great if I could download the package as a single single file - is it possible to upack it by an built-in method and store it as a folder with upacked (and thus readable) sub-folders and files?
when the application is downloaded, it is an apk file. Therefore it should be possible to have the sample data (i.e. downloaded with the application) at the same location as the data that will be downloaded later. How can I ensure this.
the data can be pretty large and therefore it is not an option to have all of them included in the assets folder immediate after the download and unlock it on basis of the user's actions
once the data are downloaded, they must work off-line (i.e. the user must be able to display them without internet access; thus it is not possible to check identity of the user on the server - they can simply display anything they have previously downloaded)
Example (for clarification purposes): have an application able to display recipes. It does not contain any or just a few after installation. You should be able to download recipes (one by one) from a server (each having a certain file structure stored in a seperate directory). Once they are downloaded, they become an integral part of the application and always accessible for the user even if the use the airplane mode of their phone.
Hope it makes at least some sense (I can clarify the question further if it doesn't). I've found several tutorials on how to work with data stored in assets and on how to handle data on an sd card but none concerning this particular topic.
you may store your date in your application data folder, basically it's available to your application only. if you want to prevent your data to be copied to another phone, generate a random UUID on the first run, and then use it to encrypt your data stored in the data folder. another phone will have different UUID and different encryption key, making it pointless trying to copy encrypted data. you may even use non-symmetrical encryption and send your generated (public) key to the server and have the server to encode your data and send it back in encrypted form, thus preventing your data to be exposed at all.
the assets/ folder is generally read-only, you may put your data there only during the build step.
make your file a .zip file -- these are compact and you may easily read files and folders and whatever you need using java.util.zip.ZipFile
sample data goes into assets folder, you may copy it out to the data folder on the first run.
once you download the data and save it to the device, i don't see any reason why your application won't work offline