How to clear an Android device without losing root?
Performing a factory reset doesn't make you lose root access, since the root handling app (SuperSU or KingUser or whatever) is installed as a system app and only the /data and /cache partitions are formatted by a factory reset. The /system partition remains unaffected.