I am creating an application in Jetpack Compose Desktop which will take user input and after user reopens the application that input value should be there. I mean a user given data should be there after user reopens the application.
remember { mutableStateOf } doesn't work here
I didn't get tag for jetpack compose desktop so I have android Jetpack Compose tag
The remember will only save data while the current view is visible on the screen. Check out more about state it compose in documentation.
If you need to save something between application runs, you need to save it to a database or write it to a file and read it when the application runs.
One way of doing this is to use the Java Preference API to store Key/Value based values.
If you need more complicated data, you would need to store your data into a File or a database.
Related
I am building a desktop application using Angular 13. to build the desktop application I am using electron JS along with Angular 13. here I've requirement to store a data in the local system.
So I need your help like which process I need to follow to store the data in the local system. also I want to display a data inside application in a list format.
Right now i'm doing but facing an issue, please review below details I have 1 JSON files on the client-side which are basically an array of JSON objects, from where I read and use in my component. I want to add (or edit) an object in those JSON files using angular only(without sending it to backend) and then make sure component is able to use it. Is it possible through angular? Or will I have to use a typescript file and store all information there?
I need to store the data inside the operating system as the data will be in large amount
Please if there is any other way that we can store this data in local system and show it in the application then please help me.
I have this form add form
and store this form data in local(os), get that data in listing page list form data,
and able to do curd on listing page ,
Thanks an advance
can't use backend apis
When working with a database on Firebase, is it possible from within an iOS app to check the date(& time) a document was last updated using some standard API? I mean without implementing my own system to know when it was last time touched.
It would be convenient if there was a field "lastUpdate" time-stamp for instance.
Neither the Firebase Realtime Database nor Cloud Firestore automatically adds a timestamp field to the data for writes.
If you want such a field, you will have to add it yourself, either from the client, or from Cloud Functions.
For a simple example of the latter, which tracks when a node in the database was last modified, see this folder in the functions-samples repo. The main code:
exports.touch = functions.database.ref('/chat/{message}').onWrite(
(change, context) => admin.database().ref('/lastmodified').set(context.timestamp));
I can't seem to locate a built in mechanism to store user settings. I was hoping that electron provided a standard method for storing user settings across all desktop platforms. If there isn't a precedent for this I can implement it myself, I just didn't want to jump to a custom solution immediately. Research online is pretty sparse in this area. Thanks!
Each platform has different default locations for different kinds of data. So, if you want to store data in default locations based on platform, check out app.getPath(name)
It retrieves a path to a special directory or file associated with name.
You can also use it to differentiate between data the user wants to save, and data your application saves that you don't want to clutter up users directories.
Or if you just want to store files reletive to a specific path you can use the
app.setPath(name,path)
I've faced this particular problem with my Electron app and this post inspired me to write an NPM module called electron-json-storage.
This module allows to easily write/read JSON to/from app.getPath('userData'):
const storage = require('electron-json-storage');
// Write
storage.set('foobar', { foo: 'bar' }).then(function() {
// Read
storage.get('foobar').then(function(object) {
console.log(object.foo);
// will print "bar"
});
});
Electron doesn't give you anything out of the box for this. However, Electron does give you a method for getting the idiomatic location of storing user data in a cross platform way via the app.getPath API.
I'd say the 3 most common ways to do this are:
localStorage (or any HTML5 storage API)
flat JSON file (this is what I do, and I use electron-store for it)
embedded database like IndexedDB, neDB, or sqlite
Which one you choose will depend on your app's needs. If you only need to access this data in the renderer process, then I'd just use localStorage. Most of the time it seems you need to access the data in both the main and renderer, so a JSON file makes sense. If you're dealing with lots of data or complex querying, then maybe a database makes sense. I wrote about this more in detail here.
How about LocalStorage? If you need to access these settings from the browser process, you probably need to write your own (or just use a node.js library that implements this)
The best way that I have found is to store it in a simple file as JSON. The problem is that if you store that JSON in the app dir, then when you update the app, it will get wiped out. So you want to put it in the default directory for user settings for the current operating system. LUCKILY!!!!! There is a library for node developers that will help you find the userdata directory. The module is called appdirectory, and I have used it several times. It is extremely easy to use.
See APPDIRECTORY HERE
One could store data in cookies; Electron has a mechanism for it (https://electronjs.org/docs/api/cookies) and the cookies can be retrieved in the browser (Angular: https://docs.angularjs.org/api/ngCookies/service/$cookies, React/Other: https://github.com/reactivestack/cookies)
I was able to get it working with Angularjs.
I need some help with a CouchDB iOS project.
I'm using Apache CouchDB Server and the couchbase-lite iOS Framework.
On my CouchDB I have a template document.
- CouchDB Server
- database
- template
- document 1
- document 2
- ...
My goal is to only synchronise my iPad with this template document to get the latest data which my application needs.
But when I enter some data on my iPad, I want that this data should be pushed only to couchBase Server.
How can I "tell" my application to synchronise only one file and not the entire database with my server and at the end how can I "tell" my application to only push the data that is input from user side ?
More importantly, Do I need two databases on my server? One for the template and a second one for user input data?
If YES, then I just need to know how I can only push my data.
Guidance needed. Thanks.
This is how I solve this:
I tend to add a 'last update' date to all my documents, and store this in a format that means they'll be sorted in time order (epoch or yyymmddhhmmss) both do.
Create a view that uses the update time as a date.
On your client, store the time since you last updated.
When you update, access the view with a startkey parameter set to the last update date.
You can then either use 'include-docs=true' to get the documents as you query the view.
I tend to use 'include-docs=false' though as it means when a lot of documents have been updated I transfer less data in a single query. I then just directly access each document id that the view returns.
I'm working on web application which, among other things, needs to save small file to particular folder on user's hard drive whenever user clicks a button. That file will serve as input for another desktop application so it must be saved in predefined folder and predefined format. "Save as..." and save dialog would be very inconvenient. Also setting that all downloads go to that folder would be troublesome.
Also, changing desktop application is not an option.
In current stage of web browsers and web standards what would be the best approach?
Is it development of custom plug in for browser? Or flash/silverlight? Something else?
First of all this is not doable via http and html.
If this is a controlled environment maybe you could get away with simply providing a customized portable firefox to your users. Of course, all other downloads would go to that folder as well.
Anything thats loaded from a website isn't allowed to access the computers HD, and with good reason.
That aside; Could you give it a new extension and associate a program with it that saves it in the correct place, all the user then needs to do is check 'always do this action' or something to open the file with the program when the button is clicked.
Perhaps a different approach would be to have the desktop application retrieve the file from your web-application when it needs it - is this feasible?
This approach means you need not concern yourself with the sandboxing protection of web browsers that prevent web-applications knowing too much about the clients file-system.