2014년 12월 27일 토요일

Save list to file when screen closes

in my app I collect data in a several lists.
When the screen closes, I want to store these lists in csv-files.
How can I do that ?
Is there a possibilty to do something, when the screen closes?



You can easily save it to a TinyDB.  Just give it a key, and store the CSV string as the value.



The question is, if I have to store the list whenever a single data changes.
This makes the app slow and I don't know, if it is a good thing for the sdcard, when I do thousands of write accesses.
So I would prefer to store the lists, when the screen closes.  



If your data changes frequently and you're storing it frequently, you're probably not doing things efficiently.

Please post screenshots of your relevant blocks and we'll try to help you out as well as we can, but we can't help you without seeing what and how you're doing things.  The only thing that'll make your app slow is sloppy programming.  Writing data from time to time shouldn't do it.  You should be naipulating your data in lists and writing it to the device only when you're ready to leave and read it when you come back.



My app is a vocabulary test. I have several lists of vocabulary. Lists of Lists. Every list has 900 items of 10 items. One of the item of the items shows, how often every single vocabulary has been requested. So every time I request a vocabulary, the app increase the value of one item. And every time, the app does this, the whole list of 9000 items get stored to the csv-file. I think, it is not good, that everytime one item changes, the whole file is stored. I would prefer to store the file (with all changes) one time, when the screen closes. But there seems to be no possibility to do so. 




you can create an "Exit" button for the app and store the file in the Exit.Click event
however your user also can close the app using the menu buttons and in this case the list would not be saved

alternatively you could try to store the list in TinyDB....
well, probably this does not help, because TinyDB is only a XML file in the file system too, but it would be interesting to know, if TinyDB is faster than the File component...
let us know what you find out...



How many write accesses can a memory cell stand ?
If that doesn't matter, it would be a relief.
Is this a criterion a software programmer should take heed of.



Here is a generic answer regarding write access to a memory card:



Should you be concerned?   It depends on how important the data is.  If data is very important, you should store a copy somewhere else.
What the article indicates, is that you will probably buy a new device before your memory wears out (unless there was a defect in the memory chip).


댓글 없음:

댓글 쓰기