keep DB data after sleep

Tadder

Member
Licensed User
Longtime User
when my app first opens it runs a few SQL queries to a remote MySQL server and stores the data in a listview, and also a separate searchview. If I go to another app, and then come back to the first app soon after, it's fine as all the data is still there.

I left the app open (did not force close it) last night and opened it back up this morning (after about 5hrs). it brought up the page where I left off, as expected, but the listview and searchview info where no longer populated.

is this normal?
 

Informatix

Expert
Licensed User
Longtime User
when my app first opens it runs a few SQL queries to a remote MySQL server and stores the data in a listview, and also a separate searchview. If I go to another app, and then come back to the first app soon after, it's fine as all the data is still there.

I left the app open (did not force close it) last night and opened it back up this morning (after about 5hrs). it brought up the page where I left off, as expected, but the listview and searchview info where no longer populated.

is this normal?

Yes. When Android is short of resources, it collects the data of paused activities to free memory. That's why I added a state manager to UltimateListView (SaveState/LoadState). When the application gets paused, all data are saved to disk and reloaded when the application is resumed.
 
Upvote 0

Tadder

Member
Licensed User
Longtime User
Yes. When Android is short of resources, it collects the data of paused activities to free memory. That's why I added a state manager to UltimateListView (SaveState/LoadState). When the application gets paused, all data are saved to disk and reloaded when the application is resumed.

so is that data saved to the disk and then deleted once it's reloaded? i considered saving the data to a csv once the DB query runs and reloading from that, but I do not want a local 'readable' copy of the data on the user device. i want it only accessible through the app.

As you probably know, I did buy ULV, but have not had the chance to try it out in an app yet. I like Searchview as it is updated in real time as I type in characters. I like/need that feature. can ULV do that?
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
so is that data saved to the disk and then deleted once it's reloaded?

Once reloaded, the files are not deleted (you have to use DeleteStateFiles explicitely) because these files are small and can be useful if the application is closed abruptly and cannot save again its state. There are no sensitive data in these files (no data coming from your DB for example).

i considered saving the data to a csv once the DB query runs and reloading from that, but I do not want a local 'readable' copy of the data on the user device. i want it only accessible through the app.

Why do you want to do this? Why don't you copy the queried data in a local database?
EDIT: if you don't want that the local DB contents is easily readable, you can encrypt its data with SQLCipher.

I like Searchview as it is updated in real time as I type in characters. I like/need that feature. can ULV do that?

SearchView is a class made with the B4A ListView. If you want to use the ULV as the list view of SearchView, you have to modify SearchView, not the ULV.
 
Last edited:
Upvote 0

Tadder

Member
Licensed User
Longtime User
OK i'll play around with that. I don't think that I need to use ULV in this project, as I'm already using a table to show ALL the parts after the user picks a category. pics don't need to be shown until after the user picks a product, and that is on it's own activity by itself.

I'm using the SearchView in another section - as an alternate way of finding parts, by typing in my part# or a manufacturer part# which then narrows it down. the issue with saving the data locally is that the data will not be refreshed regularly (only when the user logs out, and back in)... i suppose i could set a last refresh and check against it every once in a while.. i'll figure that out.

I'm not sure, at all whatsoever how to do anything you've described, but hey, noobs will be noobs, right? :sign0104:
 
Upvote 0
Top