问题
When I want to delete a class or a layout, I get a popup asking me do I want to "Safe Delete" it.
I wanted to know what exactly are all of the options, but i cannot find any nice answers out there.
So what do all of these three options mean exactly?
回答1:
With safe delete Android Studio will search if your "WebViewA" is used in another file or not, so it won't cause any error if you delete it.
For example if you are using class WebViewA in MyActivity class and then you delete the WebViewA class without safe delete, there will be a new error in MyActivity class.
This is the example of safe delete :
I tried to delete BluetoothUtility class and I used safe delete and then Android studio detect there are 2 usages of BluetoothUtility
After selecting View Usages I can find that I used BluetoothUtility in MyActivity class. And I can also do refactor from it.
I hope my explanation is clear enough! :)
回答2:
Safe Delete works into Android Studio as same as other development environment based on IntelliJ IDEA.
It says that
You can safely remove classes, interfaces, methods, fields, and parameters, keeping the code working and error-free. The Safe Delete Refactoring finds all the usages of the selected symbol within the open project or simply delete the symbol if no usages found.
Ref : Re-factoring into IntelliJ
You can read more about at Safe Delete doc from IntelliJ
来源:https://stackoverflow.com/questions/26274473/what-is-a-safe-delete-in-android-studio