0

I was coding my android program on Android Studio and I made quite a progress on it. I remember I copied all the codes in my colors.xml (ctrl+A) when this happened. I was thinking to change the background image of my app so I deleted my background image in my drawable folder unchecking the "safe delete" option.

When the background image was deleted, I put another image using batch drawable import hoping that it would exchange the background image of my app, but it didn't. I tried to change the background image by linking the image in my code in the layout folder, same results. So I thought I could invalidate caches and restart hoping to fix the problem.

To my surprise my whole project was a mess, the errors where from my build gradle, all of the codes were changed! It was replaced by the codes used in the colors.xml

enter image description here

Now I can't do anything, I think I'm going to redo the whole project now but it'll take quite the time. So I'm asking here why it happened, or is there any possible solution as to I could recover my project codes? Thanks!

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • 1
    This is a wake-up call to start using a version control like `git`. Everything can be happened while you're coding; crash, RAM broken, hdd crash, etc. Make a backup – ישו אוהב אותך Mar 23 '19 at 06:18
  • @ישואוהבאותך as he said, start using a vcs and also start keeping remote backups on Github or any cloud vcs of your choice to keep it safe from failing local storage. – MD Naseem Ashraf Mar 23 '19 at 09:17
  • Possible duplicate of [Android Studio shows wrong file contents](https://stackoverflow.com/questions/53249677/android-studio-shows-wrong-file-contents) – Zoe Mar 23 '19 at 09:40

1 Answers1

1

is there any possible solution as to I could recover my project codes?

Yes. You have few options to recover your project. One option is revert your project code which I normally do.

Right click app ---> Local History ---> Show History

Then you can select which file or time you want to revert.

John Joe
  • 12,412
  • 16
  • 70
  • 135