I just can't figure out why I'm getting this error, I'm doing the exact same thing in another class, and it works fine (maybe it's an import?)
I want to do this:
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String downloadKey = getString(R.string.pref_download_folder_key); // This will return "pref_download_folder"
String downloadDefault = getString(R.string.pref_download_folder_default);
DownloadFolder = sharedPref.getString(downloadKey, downloadDefault);
But I'm getting the following error:
Wrong argument count, format string pref_download_folder requires 0 but format call supplies 1
When I change the line to this, everything works fine (note the downloadDefault works, despite being the exact same method):
DownloadFolder = sharedPref.getString("pref_download_folder", downloadDefault);
Thanks in advance!
It's an Android Studio bug. http://code.google.com/p/android/issues/detail?id=53238
Pressing "run" ran for me fine. You can also invoke
gradlew assembleDebug
or
gradlew assembleRelease
to build from a command line.
Edit: this is fixed a while ago, so if you see this in recent versions of Android Studio it's most likely the bug is in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With