1. A method for media file management for use in an electronic device, comprising: providing a music file, wherein the music file is divided into a plurality of music samples; analyzing the music file to calculate a gain for each music sample, wherein the gain is a difference between an original sound loudness and a target sound loudness; detecting at least one valley point based on the gains of the respective music samples; selecting a first specific valley point from the at least one valley point, and setting the first specific valley point as a start of a music segmentation; selecting a second specific valley point from the at least one valley point, and setting the second specific valley point as an end of the music segmentation; and generating media data for a plurality of media files in the electronic device based on the music segmentation.