How to handle drag and drop in Android App using Appium?

Using the TouchAction class we can handle drag and drop. Below is the for the handling of drag and drop:

TouchAction action=new TouchAction((MobileDriver)driver);
action.longPress(ElementOption.element(source)).moveTo(ElementOption.element(target)).release().perform();