Rahul Khurana Rahul Khurana - 3 months ago 29
Android Question

Static variable used in project android studio

How do i find where static variable are used in android studio project? Is there any way to find such variables . As my project is too big and i want to remove possible memory leaks. Help me to achieve this. Thanks


I have been using this trick for a very long time now. I am sure this will definitely help you. Follow the instructions step by step and this will help...

Project Search

  1. If you are using windows, Press Ctrl + Shift + F to open entire project search...
  2. Next, In the text to find add this Regex (public|private|protected) static and under options select case sensitive and Regular expression. This will match public static or private static or protected static.
  3. In the scope, select the project production files
  4. Set the file mask as *.java
  5. Set the context as except comments and string literals

When you hit Find, you will get 1000's of results. You will find results like this:

Search results

Completely ignore the usages in generated code.... IMPORTANT

Only search in the found occurences for your static variables.

PS :

  1. One drawback with this is that this will match static methods too... such as public static int randomMethod() { }
  2. If your static variables don't have access specifiers such as public private or protected, just use regex as static .