What is "Safe Delete" in Android Studio?

When I want to remove a class or layout, I get a popup asking if I want to "safely remove" it.

I wanted to know exactly what the options are, but I can't seem to find any good answers.

So what do all three of these options mean?

enter image description here


source to share

2 answers

With Safe Removal, Android Studio will search if your "WebViewA" is used in another file or not, so it won't throw any errors if you remove it.

For example, if you use the WebViewA class in the MyActivity class and then you delete the WebViewA class without safely deleting, a new error will appear in the MyActivity class.

This is an example of safe deletion:

I tried to delete the BluetoothUtility class and I used safe delete and then found that there are 2 BluetoothUtility modes in android studio

enter image description here

After selecting View Usages, I can find that I was using BluetoothUtility in the MyActivity class. And I can refactor as well.

enter image description here

Hope my explanation is clear enough! :)



Safe deletion works in Android Studio in the same way as it does in other IntelliJ IDEA-based development environments.

It says that

You can safely remove classes, interfaces, methods, fields and parameters, keeping your code running and error free. The Safe Delete refactoring finds all uses of the selected symbol in the open project, or simply deletes the symbol if no search is found.

Ref: Refactoring in IntelliJ

You can read more about Safely Delete Document from IntelliJ



All Articles