The following trick will teach you how to install Android M on your Nexus device. The new Android operating system is currently available for the following devices Google Nexus 5, Google Nexus 6, Google Nexus 9, and Google Nexus Player.
Before starting the process it is highly recommended to create a full back up of your android smartphone, then follow the following steps.
You will need to download and install the latest Android Studio Preview on your Windows computer. This installs the ADB and Fastboot programmes, which can be accessed through the command terminal on your PC.
Add the SDK folder to the PATH by following these steps:
Right click My Computer and click on Properties.
Click on Advanced System Settings.
Click on System Properties > Advanced > Environment Variables.
In the Window, select Path, then click on Edit, and then type in the name of the directory where you installed the SDK, and remember that each entry is separated by a semi-colon.
Enable USB debugging on your device. First, go to Settings > About Phone > Software information.
Tap Build number seven times.
Go to Settings > Developer options. Tick USB debugging.
Download the correct factory image for your device.
ie: for Android M for Nexus 5 or for Nexus 6 for Nexus 9
Extract the image on your computer.
Connect your device to your computer over USB.
Start the device in fastboot mode.