Stack Overflow Community
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? :(
You probably should have taken a break hours ago, but you are just so close! Then all of a sudden, you realize that a core section of your project is gone, and you cannot for the life of you remember how you did it. However, today we are going to focus more on the solutions to recover deleted files in Android Studio rather than pour salt on the wound. If you're experiencing an accidental deletion in Android Studio or in any other IDE, keep reading.
When it comes to programming, accidents or data loss can happen all too often. Don't worry, even if you can not find anything in the default trash can. Just follow the steps below, restoring deleted files in Android Studio can become much easier.
Unlike version control systems that only track changes between commits, local history records your project's revisions as you edit code, run tests, deploy applications, and so on. You can actually solve most of your issues from local history, which lets you restore deleted files, bring back separate changes, or roll back to any state of a file. If you messed up some features and need to get back to the previous version of the project, it is also the easiest way for you.
Step 1. Switch view to Android in the left part of the Android Studio, right-click the class file (app node).
Step 2. Move to Local History. Local History should be near the bottom of the list of options and shows the most recent changes that you have made to your programs. Click Show History.
You can select any folder in the browser and check the Local History (i.e. the app directory).
Step 3. Find the version you desire there, right-click it and choose Revert selection.
Now, your whole project in Android Studio will be restored to the state you desire. Do not remember where the deleted file was housed? No need to worry! We have some more viable options for recovering those files. The key to this resides in the recent changes section. This method effectively helps you undo a deleted file in Android Studio.
Step 1. Follow this Path: View > Recent Changes
Step 2. Select the Deleted File. Click Revert. And just like that, your file is back!
If you accidentally deleted your whole project folder in Android Studio and dont know how to retrieve it. Try these：
Firstly, create a new project with same name and same package name. Then, try to create new files with the same names as your deleted files. After that right-click the project folder and select Local History > Show History. Fortunately, Android Studio keeps track of all changes. This will help you.
Can't find anything you desire in Local History and you local hard drives? In this situation, the only solution for you to restore the lost files in Android Studio is using the third party data recovery software.
As a professional data recovery program, AnyRecover should be able to handle any lingering issues with your deleted files. If you don't have any backup, it is the last way for you to retrieve the files and back to work in Android Studio ASAP.
You're in luck! There is no need to shell out a fortune for getting your precious files back on your first go. Any Recover offers a free trial for up to 8 files recovery without any size limitation.
Features of AnyRecover:
Okay, now how do you use it? Well, that's simple, especially since it can solve your current or first batch of problems with the free trial.
Step 1 Download and launch AnyRecover. Select which drive your missing files were in. You can go through multiple drives, but for now, select the drive you think is most likely to contain your lost files.
Step 2 After selecting the specific location, the program will begin searching for lost files.
Step 3 After the scan, a list of lost files will appear. From there you can double-click on the file to preview it before selecting the Recover buttom.
The Local History is configured by default to store revisions for the last 5 working days (the days on which the file was modified).
Press Ctrl+Shift+A in your keyboard. You can choose Help | Find Action from the main menu instead. Type in Registry in the popup window. Next, select the corresponding item and press Enter.
In the Registry editor, locate the localHistory.daysToKeep key and change its value.
Click Close and restart Android Studio for the changes to take effect.
By configuring JVM options, you can pass the localHistory.daysToKeep parameter as a Java property. To set retention to 30 days, Follow the step below:
Add the line DlocalHistory.daysToKeep=30 into the JVM options file.
However, if you want to disable Local History completely, change the retention period to 0.
By Greyson Cyrus , to PC Data Recovery
Updated: Sep 16, 2021