60

Is it possible to recover a deleted XML file from app in Android IDE?

Unfortunately I deleted important files from my app.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
prakash
  • 1,413
  • 1
  • 21
  • 33
  • 3
    Take a half hour to get yourself familiar with a source control tool, such as git. It won't help you this time, but it'll reduce the likelihood of you losing valuable time in the future. – 323go Apr 21 '14 at 13:45

3 Answers3

225

For Eclipse:

To restore a deleted Workbench resource with a state from the local history:

  1. In one of the navigation views, select the folder or project into which you want to restore a local history state
  2. From the resource's pop-up menu, select Restore from Local History.... The Restore From Local History dialog opens showing all files that were previously contained in the selected folder or project and all of their sub-folders.
  3. Check the files that you want to restore
  4. If you don't want to restore just the last state of a file you can select any other state of the file from the Local History list on the right hand side of the dialog. The bottom pane of the dialog shows the contents of the state.
  5. If you are done with all files click Restore.

(Source)

For Android Studio / IntelliJ / AppCode:

  1. Go to the Project tool window and right-click the project node or just a folder, where the file used to exist
  2. On the context menu, choose Local History, and click Show History on the submenu
  3. The local history view for a project or folder shows you everything that you have done during the last few days. In the Action column of the lower part of the dialog box, select the action you want to roll back. In our case, this is the Deleting action. So doing, the upper part of the dialog box shows the tree view of changed files.
  4. If you want to restore the deleted file only, regardless of the other changes that have been done since then, you can select the file Lost.txt in the tree view and click the Revert button on the upper toolbar. The file will be restored silently.

(Source)

Community
  • 1
  • 1
Tom
  • 5,068
  • 5
  • 29
  • 41
  • 4
    for anyone who's fooled by show history being greyed out on drawable folder (as was for me), if you right click and show history on the app or res folder the local history does in fact let you restore the drawables. – Ramin Oct 13 '17 at 15:21
18

UPDATED SHORT ALTERNATIVE:

Android Studio:

  1. Go to Project Window tool
  2. Expand res folder
  3. Right click on layout and Place cursor on Local History (it is perhaps the 5th or 6th last option)
  4. Select Show history

here we have all the past versions available, right click a version which you want to roll back and select Revert!

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Salman Anjum
  • 333
  • 3
  • 7
  • 1
    This works for directories as well. I accidentally deleted my drawable folder and got it back this way. Thanks a bunch! – cht Sep 25 '19 at 08:05
0

Press Ctrl +Shift + E (Recently changed files)

and restore those file via revert..

It is under Toolbar -> View -> Recently changed files

Andrew
  • 101
  • 1
  • 10
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300