processing / processing-android

Processing mode and core library to create Android apps with Processing
http://android.processing.org
779 stars 293 forks source link

Attributes and their values are not getting saved properly in preferences.text #700

Closed rupeshkumar22 closed 2 years ago

rupeshkumar22 commented 2 years ago

It's strange that Preferences.set("android.sdk.path", folder.getAbsolutePath()); not committing the changes to the preferences.txt file. During runtime if logs are used- Preferences.get("android.sdk.path") returns the correct value just after Preferences.set("android.sdk.path", folder.getAbsolutePath()); But after closing the program Preferences.txt file does not contain the attribute and value. So the next time on program startup load returns null as the value was not stored earlier in preferences.txt file not even with Preferences.set("android.sdk.path", folder.getAbsolutePath());

Steps to reproduce- Remove the variable ANDROID_SDK from eclipse if using, and delete the preferences.txt folder. Remove any system environment with ANDROID_SDK if present. On startup, it shows "cannot find an Android SDK" dialog box. Choose any option either "choose sdk path mannually" or "download SDK automatically. After the process, values are not getting saved as "android.sdk.path" in the preferences.txt file. Restarting the program opens the same dialog again and Preferences.get("android.sdk.path") returns null on logs. I have confirmed the SDK path was used without any space in Preference.set and was accessible by Preferences.get on runtime.

codeanticode commented 2 years ago

@rupeshkumar22 I think the issue is that Preferences.set() does not save the preferences to the file immediately, the PDE writes to the preferences.txt file only on exit.

rupeshkumar22 commented 2 years ago

@codeanticode thanks for the information, I checked the file after closing PDE window. Might be the case that process was running in background. I will check again. Thanks!

rupeshkumar22 commented 2 years ago

After closing the PDE properly, The values were getting saved, Thanks for the information.