In order to maintain a healthy living both physiologically and psychologically, it is important for patients with mild cognitive impairment (MCI) to maintain active in daily life. In this paper, we demonstrate how to use simple motion sensors, e.g. accelerometers, gyroscopes and magnetometers, to design and develop a system, called ActiveLife, for effective tracking of the daily living activities of MCI patients within their living rooms. In order to simplify the activity detection process, in ActiveLife, we adopt the context-based approach to model the common activities performed by the user within a day. Since the accelerometer and gyroscope are tri-axial sensors, the sensor data for different axes can be used to predict the current posture of the user while he is performing an activity. Combining with the heading direction of the posture obtained from the magnetometer and distance traveled during the transition of activities, we can estimate the current activity of the user. To further improve the estimation accuracy, we have designed an algorithm using the machine-learning technique, i.e. support vector machines (SVM), for activity classification.