What is a “Safe Delete” in Android studio?

淺唱寂寞╮ 提交于 2021-02-07 14:34:42

问题


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?

enter image description here


回答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

enter image description here

After selecting View Usages I can find that I used BluetoothUtility in MyActivity class. And I can also do refactor from it.

enter image description here

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!