Settings not saved on devices

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

In my app users can select various settings.
These settings are saved in a database.

On my devices the users settings are saved and reloaded fine, however users report that the settings are not saved on their devices.

I use a Galaxy Note, HTC Legend and two cheap tablets.

Update and curser.close are used of course and the database is a .jpg file.

Thanks very much in advance.
Helen.
 

JonPM

Well-Known Member
Licensed User
Longtime User
You'll have to post some code or perhaps the link to the APK so we can test it. Not really sure how else we can help. Also, what do you mean the database is a jpg file?
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hi Jon and others,

Included is the zipped apk.
The database has a .jpg extension because the original db is more than 1MB

It should be clear which settings have to be saved.

Thank you.
Helen.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Hi Merlot
I think that the problem might be that you declare Dim ST as SQL in Process_Globes in several modules.
I'd suggest you to declare it only in the Main module and call it in the other modules with Main.ST and initialize it also only once.

Best regards.
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hello Klaus,

Oh, oh, oh, that would be something if this error is the cause.
I wonder why I did't see that you can also call SQL from another module.

Well, I will start rewriting the complete app one of these days - only lately coding starts to sink in (see the Voices module :eek:).

I will let you know the result asap and, as always, a big thank you.

Helen.
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hello again,

Even though Klaus gave me the hint to skip all the wrong initializing, etc.: it didn't solve the saving issue.

Two cents for my thoughts:
.jpg file permissions?
Release (obfuscated)?

It's a bit annoying that my devices don't show this error.
The uploaded zip only contains 40 records with bird names. The real world version has 11.000 records.

Thanks,
Helen.

Edit: maybe 3 cents:
A tester just mentioned that in the 'application info' the data is Zero. So I could solve the problem by creating a separate .sql database for the settings
Remains: am I doing something wrong or ..........?
 
Last edited:
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Are you seeing errors in your Android Dev console? I didn't look at your project but possibly it is related to this problem that seems to affect some devices. If you are using those folders that could possibly be it. Errors in the console might help prove that, but only if the users are sending the crash reports in.

In short, on some devices File.getDirInternalCache returns null and causes an error. If you are trapping errors, it could very well just be skipping right over the save or load part.

Erel said that the issue retreiving File.getDirInternalCache was fixed in that it will automatically try returning File.getDirInternal instead if File.getDirInternalCache returns an error. But what I am seeing now is some devices cannot return File.getDirInternal either. If that happens, then what other folder can you use other than something on the SD card, if it is available?

Supposedly you can sometimes resolve the above problems by uninstalling and reinstalling the app. Worth a short if your customers haven't tried that yet.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
I don't think that it is related to the File.DirInternalCache returning null issue. This was fixed in a previous version.

I did mention that, but what I'm wondering is if the devices cannot return File.DirInternal either, which depending on how her code is written, may not crash the app but could possibly prevent settings from saving or loading.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I had a second look at your code and found the following:
In Main Activity_Create you have this code:
B4X:
    If FirstTime = True Then
        myla = "EN"
        langu = "EN"
        region = 0
        File.Copy(File.DirAssets,"birds_world.jpg", File.DirDefaultExternal,"birds_world.jpg")
        
'        ToastMessageShow("The search language is set to English. To change the language press the MENU-button", True)
        StartActivity(MyLangRegion)
    Else
        region = MyLangRegion.region
        myla = MyLangRegion.myla
        langu = Taal.searchLang
    End If
    
    If ST.IsInitialized = False Then
        ST.Initialize(File.DirDefaultExternal, "birds_world.jpg", False)
    End If
Every time the system killes the application you load the default database so the usere setting are lost. FirstTime doesn't mean the very first time but the first time after the application was killed.
I replaced it by following code
B4X:
    If FirstTime = True Then
        If File.Exists(File.DirDefaultExternal,"birds_world.jpg") = False Then
            File.Copy(File.DirAssets,"birds_world.jpg", File.DirDefaultExternal,"birds_world.jpg")
            ST.Initialize(File.DirDefaultExternal, "birds_world.jpg", False)
            StartActivity(MyLangRegion)
        Else
            ST.Initialize(File.DirDefaultExternal, "birds_world.jpg", False)
        End If
    End If
    
    ' klaus here you need to read these values from your datatbase and not the values below
    myla = "EN"
    langu = "FR"
    region = 4
You need to read in the code above the values in the database, I haven't seen any reading of these values in your code.

Attached a modified version that seems to works but haven't tested everything.
I left the variables myla, langu and region in Main as process global variables and removed the Dim as process globals in the other modules and added Main as prefix in these modules.

Best regards.
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hello Klaus,

After reading your explanation about FirstTime I said "Ohwwwwwww".
Must have been misunderstanding this a long time ago.
One issue that I don't get: how is it possible that it did work fine on my devices?
I have been testing every possible way and never ran in to the non saving/loading issue.
Well, today I can't think at all (42+ degrees, ha, ha). Hopefully it goes better tomorrow.

Thank you so much.
Best regards to a great teacher and analist.

Helen.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
One issue that I don't get: how is it possible that it did work fine on my devices?
Probably during testing on your device the system never killed the application.
During first testing of your program I was also noticing it works well, but without any killing of the application. The problem during testing is that as long as the system doesn't need more memory the applicaion will not be killed.

But then looking closer at the code I saw the problem.

Best regards.
 
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Klaus,

Aha, so that was it, beside my errors in coding.
Thank you for explaining me and have a nice day.

Helen.
 
Upvote 0
Top