Where should the data for Android apps be saved?

Source: Internet
Author: User

Android app development will involve the preservation of different data, such as data cache, customer login information preservation, customer status preservation and so on.

So where do we keep the different data?

1, the application uninstall also will not delete data

Create a folder directly in the SDcard root directory to save the data.

Advantages: Long save time, application uninstall will not be deleted. Cons: Anyone can access this directory.

2, following the existence of the application of data

The Context.getexternalfilesdir () method can get the package name to sdcard/android/data/your app/files/

The above directory will be removed as the app is uninstalled, this directory corresponds to the "Erase data" option in the app-to-application details of Android phone settings, which will be deleted when the user clicks this.

Context.getfilesdir () can get to "/data/data/<package Name>/files" This method gets to the files directory under the app's installation directory.

3, the application of the cache directory system will be automatically scheduled cleanup,

      < Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " > context.g The Etexternalcachedir () method can get to sdcard/android/data/your app package name/cache/     

The above directory is the cache directory of the SD card, which can beStore temporary cache data This directory corresponds to settings--Application---application details in the "clear cache, the user click on this option will clear the data in this directory

< Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " > < Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " > < Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " >    

< Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " > < Span style= "color: #444444; font-family: ' Microsoft yahei ', Tahoma,simsun; font-size:14px; line-height:21px; " >     context.    Application installation directory cache directory


http://blog.csdn.net/yihui823/article/details/6722456

Where should the data for Android apps be saved?

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.