20

I'm working on an app at the moment, and one of the final steps was to get it built and signed in Android studio.

Unfortunately I was having some problems, and one of the recommended solutions was to remove the project and start again, however when I did this it took all of my files with it, and they're not in the trash (OSX) either.

Is there anyway to recover these files, or are they lost forever? :(

Nick
  • 3,745
  • 20
  • 56
  • 75

5 Answers5

57

In my case I was looking for the file named 'landing_page222.java' which I deleted one day back.

Following Steps can help you to find your previously deleted files in Android Studio.

Step 1: Right Click on the folder where you deleted the file

enter image description here

Step 2: Find option for Local History and Click Show History.

enter image description here

Step 3: Find your File from Given List.

Hopefully it will be available in Instance enter image description here

Step 4: Copy the code back as per need.

enter image description here

Rahul Shyokand
  • 1,255
  • 10
  • 17
  • 2
    thank you so much my friend. You really saved my 4 hours work. I recovered my deleted activity – Parmendra Singh Feb 09 '21 at 07:04
  • Omg I can kiss you right now.... looking at the general history didn't show it, and nothing else worked (Ctrl-z, revert, etc) but once I hit the local history on the specific folder like you suggested, it was there! thank you too much. Good karma coming your way! – Siavash Apr 27 '21 at 08:36
35

You can try:

  • looking for those files in the file system (perhaps they are still in your Android Studio projects folder)
  • looking in your OS's temp folder
  • using Android Studio's history feature (right-click on the Project tab > Local History > Show history)
user1301428
  • 1,743
  • 3
  • 25
  • 57
  • Thank you, looks like they're all gone, argh! :( – Nick Mar 09 '16 at 16:01
  • 1
    @Nick No backup anywhere? :( – user1301428 Mar 09 '16 at 16:04
  • No unfortunately, my PC is backed up constantly but I'm using my girlfriend's Macbook :( Thanks for the tips though! – Nick Mar 10 '16 at 09:32
  • Amazing: Android Studio's history saved me! I knew which file I had lost, so I re-created it and looked at its "history" in Android Studio. – Jyaif May 23 '20 at 02:24
  • Thank you! In my case i also deleted a local branch. But i remember the name. So i created the branch again, open a local history and revert deleted files! – Sergio Mar 31 '21 at 13:09
  • Thank you bro! I deleted my json data which migrate to roomdatabase. You save my time dear. – Kumar Santanu Oct 18 '21 at 10:13
12

Click whereever you want in the left frame (for example "drawable" file is ok) and then press CTRL+z. You are going to see "Undo delete popup" window.

And as you understand, when you press CTRL+z in Android Studio, which (XML or Java) file is active, you will undo the action on that tab. So, if you click any file on the left side and press the CTRL+z combination, you will undo the action at the file structure.

anothernode
  • 5,100
  • 13
  • 43
  • 62
9

Go to View > Recent Changes > Click on the file you want to recover > Click "Revert"

Michal
  • 366
  • 3
  • 10
1

Im late but this works. Go to the folder where u want to recover. right-click, local history. select ones you deleted and click revert. :)

Nitin Tej
  • 353
  • 1
  • 7