Live Templates are shortcuts displayed as code-completion options that, when selected, insert a code snippet that you can tab through to specify any required arguments. Live templates helps you to write more code with less efforts. Live templates contain predefined code structure.

Let us start with a line which you have used  so many times in your code.

Toast.makeText(MainActivity.this ,"message",Toast.LENGTH_SHORT).show();

You can write all the above code by typing 1 word Toast and pressing Tab 

You can find all the Live templates in file > Settings > Editor > Live Templates


  • $className$ will return current class name. you can use this or getApplicationContext()  instead
  • “$text$” will be replaced by your given string.

You can even create your Custom Live Templates

Step 1 : Go to File > Settings > Editor > Live Templates. Click the Android group, and press the green plus button at top right side,  to add a new Live Template.

Step 2 : Write your abbreviation and description for Live Template.

Step 3 : Write your code in Template text area :

example code :
Intent intent=new Intent($className$.this,$destinationClass$.class);

Step 5 :  click  Define at bottom of your Templateselect your coding language and click OK


That’s it you are done with your custom template, just use that abbreviation while you are coding and press Tab , all the code snippets will be there in your code.