Run gradle project as java application

gradle run is not a default task in gradle. To use it, you need to enable the 'application' plugin. To enable the plugin add this line to your build.gradle: apply plugin: 'application' This plugin requires one variable to be configured - the main class name: mainClassName = "com.looksok.Main" Now you can execute the gradle clean … Continue reading Run gradle project as java application

Fix: SharedPreferences not saved after app restart

It is quite common error that SharedPreference setting is being reset or cleared to default, after Android application is restarted. There are two things you have to remember. Commit changes made by prefs editor (the obvious one) prefsEditor.commit(); Clear prefs editor before using it (the tricky one) prefsEditor.clear(); The clear() method clears your preferences made by … Continue reading Fix: SharedPreferences not saved after app restart

Android tutorial: app preferences screen with shared preferences

If there is a need to give some configuration options to the user, you can implement application settings screen, along with saving these settings for application. Settings will be stored in Shared Preferences - place where it will persist and can be read in future. This is a set of key-value pairs, that are stored … Continue reading Android tutorial: app preferences screen with shared preferences