Android: is there an easy way to find all the Strings in my project?
I was searching for this myself. There is a nice way of doing this:
Right click on "src" directory -> Source -> Externalize Strings
This will find all Non-Externalize Strings and let you Externalize them.
Hope this will help :)
Edit:
This is not same as the Android -> Extract Android String.
But it can help you find all the Non-Externalize strings. Then, on each string you will have to perform:
Ctrl + 1 -> Android -> Extract Android String.
I would just open up a terminal window(putty if you are on windows) at the root directory of your project. You can then run something like the following:
grep -r --include=*.java '="[^"\r\n]*"' ./* --to look for something like this String test="text";, a string with =""
or
grep -r --include=*.java '"[^"\r\n]*"' ./* -- to look for any string, anything enclosed in ""
Of course the next part is to actually substitute the Strings into the Strings.xml, that could be scripted out as well, but may take more tinkering.
Field[] fields = R.string.class.getDeclaredFields(); // or Field[] fields = R.string.class.getFields();
String str = "";
for (int i =0; i < fields.length; i++) {
int resId = getResources().getIdentifier(fields[i].getName(), "string", getPackageName());
str += fields[i].getName() + " = ";
if (resId != 0) {
str += getResources().getString(resId);
}
str += "\n";
}
You will get all codes of strings with its values in "str" variable.