I have a big and messy string.xml file with 3000 records, which most of the values are useless and never used inside code. I want to find and omit those useless records automatically. Is there a way to find useless records inside string.xml file?

- 8,084
- 8
- 48
- 62

- 2,576
- 1
- 32
- 53
-
you can check usages of those strings which will show you if that string is used or not, however it is a lengthy task. – Pratik Vyas Jul 10 '17 at 05:22
-
2`Ctl+Alt+Shift+i` type `Unused resources` run it in the whole project. – Sunil Sunny Jul 10 '17 at 05:22
5 Answers
Right click on strings.xml
file:
Click on Refractor
and then on Remove Unused Resources
.
Click on Refractor
in the confirm Dialog Box.

- 2,378
- 20
- 29
-
2Doesn't this delete all unsued resources, not just strings? – Dmitry Smolyaninov Jan 09 '20 at 09:41
Menu -> Analyze -> Run Inspection by Name -> Unused resources
Actual resource Is there any simple way to find out unused strings in Android project?

- 1,050
- 2
- 13
- 27
I found the that using the lint check and the translations editor works like a charm.
Go Analyse -> Run inspection by name -> Unused resources.
Here i add a file mask to only show me the strings
After the check has ran go to the Translations Editor, find the key(s) right click and safe delete.
This checks of the resource can safely be deleted and deletes the key in all your locales.

- 21
- 1
- 5
I would suggest the best way would be to load the XML into objects such as Python ElementTree. import xml.etree.ElementTree You can then easily Prune all the branches down easily before exporting as an XML file. To deal with XML on a string level is a nuisance.

- 39
- 2