The uniqueness part of the famous Calabi--Yau theorem asserts that the Monge--Ampere measure of a positive hermitian metric determines the metric up to scalar. I will introduce a p-adic analogue of the result. As an application of both the complex case and the p-adic case, I will present a rigidity theorem for the set of preperiodic points for an algebraic dynamical system.