Tip for familiarizing yourself with the codebase of a GUI application: grep the source code for strings you see in the GUI to find the code that handles that part of the application.

@be Also helps when you do not have the source code and its time for some reverse engineering.

@be Great tip! Works for CLI tools too: Why is it throwing this error? Grep the error message, or parts of the error message.


I was about to say "but my strings are all in a translation file!" but I guess you can just search for the ID of the string.

@taylan What do you use for translations? In Qt, the canonical string goes directly in the source code and the translations are handled separately.

@be It’s the Android SDK.

Strings are defined in XML files, identified by a name attribute. The names become the fields of an auto-generated class, their values being integers that identify the string at runtime and retrieved through the getString() method of a Context instance.

So in src/main/res/values-de/strings.xml I might have:

<string name="settings_title">Einstellungen</string>

And in src/main/java/my/cool/app/ui/ I could have:

protected void onCreate() { TextView titleTextView = getView(; // We inherit from Activity which inherits from Context. // So we can just call getString() directly here. titleTextView.setText(getString(R.string.settings_title)); // Actually TextView.setText() allows a string ID directly for convenience. titleTextView.setText(R.string.settings_title); }

Sign in to participate in the conversation

For people who care about, support, or build Free, Libre, and Open Source Software (FLOSS).