In order to solve the problem that the early onset of paroxysmal atrial fibrillation is very short and difficult to detect, a detection algorithm based on sparse coding of Riemannian manifolds is proposed. The proposed method takes into account that the nonlinear manifold geometry is closer to the real feature space structure, and the computational covariance matrix is used to characterize the heart rate variability (RR interval variation), so that the data is in the Riemannian manifold space. Sparse coding is applied to the manifold, and each covariance matrix is represented as a sparse linear combination of Riemann dictionary atoms. The sparse reconstruction loss is defined by the affine invariant Riemannian metric, and the Riemann dictionary is learned by iterative method. Compared with the existing methods, this method used shorter heart rate variability signal, the calculation was simple and had no dependence on the parameters, and the better prediction accuracy was obtained. The final classification on MIT-BIH AF database resulted in a sensitivity of 99.34%, a specificity of 95.41% and an accuracy of 97.45%. At the same time, a specificity of 95.18% was realized in MIT-BIH NSR database. The high precision paroxysmal atrial fibrillation detection algorithm proposed in this paper has a potential application prospect in the long-term monitoring of wearable devices.