Reputation: 5540
Suppose Class A
with some static parameters:
public Class A {
public static final String KEY_1="key1"
public static final String KEY_2="key2"
...
}
The static parameters are used repeatedly in the project. When refactoring, I want to move them to another class, say Class B
; but doing so I have to update every use case of them, e.g. A.KEY_1
to B.KEY_2
, manually.
Is there any way to do so automatically in Android Studio or IntelliJ? What I have already tried is selecting the lines containing the parameters and pressing F6 which opens a refactoring dialog, but going through it does not get me to what I want.
Upvotes: 13
Views: 2932
Reputation: 311163
IntelliJ is really good at refactoring. Place your caret on the constant you want to move and do the following:
Upvotes: 14