12

The current Android Studio version has inbuilt auto save. Which means if you close a file, it will automatically save the changes.

This is inconvenient, it means when experimenting with code, all changes need to be noted as there's no option to have a dialog requesting to save changes on closing a tab or the project, as in many other ides.

According to documentation IntelliJ IDEA 15.0 Help/Saving and Reverting Changes:

When does IntelliJ IDEA auto save changed files?

Autosave is initiated by:

  • Compiling a project, a module or a class
  • Starting a run/debug configuration
  • Performing a version control operation such as pull, commit, push, etc.
  • Closing a file in the editor
  • Closing a project
  • Quitting the IDE

.../...

Note that those are optional autosave triggers, and you cannot turn off autosave completely.

These are the auto save settings that can be changed in Android Studio:

enter image description here

TLDR

Is there any work around to circumvent this autosave?


These questions are related, but do not acknowledge that this intended behaviour of the ide and are rather asking for fixes within the ide.

Related:

How to disable Auto Save save in Android Studio

How turn off autosave in Android Studio?

Community
  • 1
  • 1

3 Answers3

13

If you want to experiment, use the revert button at the top right. This works especially well if you are using a VCS (like git...) as it will revert to the last committed version. And since commits are still manual, this will soon replace your traditional save.

If you are not using a VCS the point in time to which it reverts is a little more arbitrary, but in my experience it takes a pretty good guess. If that doesn't suffice, you can use the history button next to the revert button, which keeps track of every version IntelliJ saved, and you can then go back to any point in time you like. :)

Kapenaar
  • 432
  • 2
  • 8
  • @MsYvette If you aren't using VCS, you can always use git to create a local repository to track your changes, and have fallback points. Git doesn't require a remote server... I know a lot of guys that started using git so they could get version control when flying and unable to reach the source control server. – Tracker1 Dec 15 '15 at 06:16
8

Android Studio as a software is very much based on the JetBrains software solutions such as IntelliJ (used for Java) and PHPStorm (used for PHP, as its name shows).

As a concept in itself, JetBrains have implemented this feature and as a company believe that it's much more efficient and productive than manual save. Hence, there is no way to disable this behavior or enable any confirmations in Android Studio either.

Taken from JetBrains FAQ for IntelliJ:

Because IntelliJ IDEA has the ability to change so many files simultaneously in large refactoring actions, and change them without ever opening them, single file saves don't make very much sense. In recognition of this, IntelliJ IDEA reserves the right to save any of your files literally whenever it wishes. It's actually quite nice to never have to worry about your file's save statuses, once you get used to it.

Having said that, and encountering this issue myself too as a developer, I agree that it would be a good idea if the Manual Save feature were enabled by the Android Engineers (or JetBrains themselves). After all it is up to the developer to choose whether he needs this feature or not.

To Jetbrain's defence, they have a very good Undo function through their Ctrl + Z shortcut keys, letting the developer go back many steps and find where a certain error has occured.

Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
  • Yes I understand you completely. I keep on hitting the Ctrl + S button on Android Studio before every build forgetting that the IDE already saved the changes I have made. – Michele La Ferla Dec 09 '15 at 12:45
  • +1 for "I agree that it would be a good idea if the Manual Save feature were enabled by the Android Engineers (or JetBrains themselves). After all it is up to the developer to choose whether he needs this feature or not." -- if only JB would recognize this ... it's a total deal breaker - too bad, much to like about IntelliJ/PyCharm. – Levon Jun 01 '16 at 16:28
6

All IntelliJ based products nowadays save any opened or modified files whenever they wish - read this as "immediately".

I would suggest you give up on trying to disable it (trust me, it's not possible to hack it) and either change your work flow or work on copies of the files.

As background I should mention that I am a plugins author for IntelliJ (with 3 publicly released plugins in the JetBrains repository) and thus have a reasonable understanding of the internal IntelliJ architecture.

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
  • Well I have been working with JetBrains integrated development environments since version 7 (we are now on version 15 of IntelliJ) and I have a pretty good knowledge of the internal workings due to being a plugins author. Not claiming to be world's best intellij user but hoping to share a helpful answer based on my experience nonetheless :) – vikingsteve Dec 10 '15 at 11:27
  • Looks like its time to upgrade my computer. It LAGS sometimes when I do something in Editor window and I can do NOTHING with that. If I work with e.g. NetBeans after disabling that 'autosave', it just flies. – CodeToLife May 29 '16 at 08:03