Android Program Development: (18) file-18.3 how to choose the best Storage Method

Source: Internet
Author: User

Previous articlesArticleThis section describes three primary methods for storing data in Android applications: sharedpreferences, internal storage, and external SD card storage. What is the method used in your application? The following are some suggestions:

1. If you have data in the form of key-value pairs, use the sharedpreferences object. For example, if you want to store some attributes of a user, such as name, skin color, birthday, or last login date, the sharedpreferences object is the best way to store the data.

2. If you want to store some special data, using internal storage is a good choice. For example, your application (such as an RSS reader) may download some images from the Internet for display. In this case, it is a good solution to save images to internal storage. It is also possible that you want to store the data created by the user, such as the user's own notes.

3. Sometimes, you need to share your application data with other users. For example, you may develop a software that records the coordinates of the places where the user has been, and shares the data with other users. In this case, save your file to the SD card, so that you can easily transfer the data to other devices for future use.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.