Getting Started with Android (18) file 18.3 How to choose the best way to store

Source: Internet
Author: User

Several previous articles described the main three ways to store data in Android applications: Sharedpreferences, internal storage, and external SD card storage. What kind of way do you use it in your application? Here are some suggestions:

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

2. If you want to store some special data, it's a good choice to use internal storage. For example, your application (such as an RSS reader) may download some pictures from the web for display. In this case, saving the picture to the internal store would be a good solution. It is also possible that you store the data that the user created himself, such as the user saving some of his own notes.

3. There are times when you need to share your application data with other users. For example, you might develop software that records the coordinates of places that users have been to, and you can share that data with other users. In this case, save your files to the SD card so that you can easily transfer the data to other devices for later use.

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.