Whenever my device (Nexus 5, Android M Preview 3) connects via USB, the USB config always defaults to \"charging only\".
This is quite problematic because the USB port
By Default, Android 6.0 does not provide an automated method to select MTP when the device is connected as USB. After much wait and research through XDA, blogs, stackoverflow etc, the best solution I found to this was a small application, named MTP enabler PRO Marshmallow(4.5 MB) - built by one of the users to overcome this problem.
This requires a rooted device.
Below is a link to download the APK file.
http://forum.xda-developers.com/android/apps-games/app-mtp-enbaler-t3263467
Below is a link to the app in PlayStore(paid app)
https://play.google.com/store/apps/details?id=mtp_enabler.esolutions4you.de.mtpenabler&hl=en
Hope it helped.