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?
The Safe Delete refactoring lets you safely remove files from the source code. To make sure that deletion is safe, PyCharm looks for the usages of the file being deleted. If such usages are found, you can explore them and make the necessary corrections in your code before the symbol is actually deleted.
Safe delete IntelliJ IDEA lets you use the Safe Delete refactoring to remove files and symbols from the source code safely. Before IntelliJ IDEA deletes a file or a symbol, it searches for usages and if they are found, IntelliJ IDEA lets you check them to make necessary adjustments.
idea/ are safe to delete, though I would have the IDE not be open on that project while you do it. If that is your only project, close Android Studio, then delete those directories using your OS file explorer or the command line. Then, reopen Android Studio, and it will recreate and re-populate those directories.
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! :)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With