26

I created a project in Android Studio (Version 1.2) and after working on that project for a few weeks, my PC suddenly shut down (Android Studio was open at that time).

After starting the PC again, I found that one of my files was completely erased.

Here is the snapshot of the workspace -

my workspace

As you can see, nothing is left on that file.

Is there any way to recover that file? I am using Ubuntu 14.04.

Adinia
  • 3,722
  • 5
  • 40
  • 58
Confuse
  • 5,646
  • 7
  • 36
  • 58

5 Answers5

56

Can you find the file in file explorer?

If you can, try to open the file through another explorer

You can find your projects path by right clicking the project and hitting "File Path"

Is there local history available?

Try right clicking the faulty file and checking Local History -> Show History

If you can fetch the local history, right click the history entry and click revert

Pasi Matalamäki
  • 1,843
  • 17
  • 14
26

you can go to VCS>Local History>show History and find from which Hour/minute you want to revert and hit revert. I've done this before and it saved my life.

db_brad
  • 903
  • 6
  • 22
  • 2
    My heart is still pounding from having almost lost 4 days of nonstop work. "Thank you" does not even begin to express the gratitude I have for this. – SlickDev Jan 25 '17 at 00:38
  • wow. Just recovered accidentally deleted package. Saved my life , thanks . – jatin rana Nov 12 '17 at 15:53
12

If the file is not exists anymore, create a new file with the exact same name then try to use VCS-> Local History-> show History.

This was the only way works for me for a new file that was saved correctly/deleted.

Raz Tourgman
  • 567
  • 5
  • 9
  • 1
    seems just a /little/ bit like voodoo! Wasn't in git, stash changes, or the filesystem...but this worked. – Ken Corey May 06 '20 at 15:50
1

This is yet another day, Android studio saved my days of hardwork when I accidentally deleted an entire project files (note: the root folder of the project was available). There were no files left to search for local history. Steps I followed as below.

Opened the root project in Android studio. enter image description here

And right click on the parent folder, from which is empty currently -> choose 'Local history' -> 'show history'.

This will show all the deleted files as 'External change' , now you can revert back to the entry before the history item marked as 'External change'. This will revert back all the 'Shift + deleted' files!

After recovery I can still see some files which are missing recent changes, which can obviously be recovered using the same process for individual files.

Now I was able to recover an entire android studio project which was 'shift+deleted'. This is a priceless moment for me :)

0

If you had already imported the project from VCS but accidentally removed the .vcs file and lost your files while cleaning your project or unrevisioned files. Just go to
Preferences -> Version Control (for mac) or Settings -> Version Control (for windows)
and we will be seeing a directory with VCS status. By selecting and applying the changes, the project automatically syncs and is updated with your previous from. Find the attached image for reference.
You can also just enable the VCS from your toolbar and sync the project.
Thanks


N:B: I couldn't find the VCS -> Local History initially because I was needed to enable the VCS first. Check my Answer



enter image description here

A S M Sayem
  • 2,010
  • 2
  • 21
  • 28