Android Persistence Technology

Source: Internet
Author: User
<span id="Label3"></p><p><p>1, file Storage.</p></p><p><p><span style="color: rgb(0, 0, 0); font-family:; font-size: 14pt; font-style: normal; font-variant: normal;">2,sharedpreferences <span style="color: rgb(0, 0, 0); font-family: 黑体; font-size: 14pt; font-style: normal; font-variant: normal;">Storage</span></span></p></p><p><p> <span style="color:rgb (0, 0, 0); font-family:; font-size:14pt; font-style:normal; font-variant:normal;">< Span style= "color:rgb (0, 0, 0); Font-family: blackbody; font-size:14pt; font-style:normal; font-variant:normal; " ><span style="color:rgb (0, 0, 0); font-family:; font-size:10pt; font-style:normal; font-variant:normal;">haredPrefere NCEs is the way to store data using Key-value Pairs. That is <br> <span style="color:rgb (0, 0, 0); font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal;"> Say that when you save a piece of data, you need to provide a corresponding key to this data, so that when reading data can be <br> <span style="color:rgb (0, 0, 0); font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal; " the corresponding value is taken out by this key. < span></span></span></span></span></p></p><p><p> <span style="color:rgb (0, 0, 0); font-family:; font-size:14pt; font-style:normal; font-variant:normal;">< Span style= "color:rgb (0, 0, 0); Font-family: blackbody; font-size:14pt; font-style:normal; font-variant:normal; " ><span style="color:rgb (0, 0, 0); font-family:; font-size:10pt; font-style:normal; font-variant:normal;"><span style="color:rgb (0, 0, 0); Font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal; "><span style="color:rgb (0, 0, 0); font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal;"> Save Data </span> </span> </span> </span> </p></p><pre class="brush:java;toolbar: true; auto-links: false;"><pre class="brush:java;toolbar:true; auto-links:false;">savedata.setonclicklistener (new OnClickListener ()  {@Overridepublic  void onclick (view v)  {sharedpreferences.editor editor =  getsharedpreferences ("data", mode_private). Edit (); editor.putstring ("name",  "Tom"); editor.putint ("age ",  28); Editor.putboolean (" married ",  false); editor.commit ();}); </pre></pre><p><p> <span style="color:rgb (0, 0, 0); font-family:; font-size:14pt; font-style:normal; font-variant:normal;">< Span style= "color:rgb (0, 0, 0); Font-family: blackbody; font-size:14pt; font-style:normal; font-variant:normal; " ><span style="color:rgb (0, 0, 0); font-family:; font-size:10pt; font-style:normal; font-variant:normal;"><span style="color:rgb (0, 0, 0); Font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal; "><span style="color:rgb (0, 0, 0); font-family: Song body; font-size:10pt; font-style:normal; font-variant:normal;"> Fetch data </span> </span> </span> </span> </p></p><pre class="brush:java;toolbar: true; auto-links: false;"><pre class="brush:java;toolbar:true; auto-links:false;">restoredata.setonclicklistener (new  Onclicklistener ()  {@Overridepublic  void onclick (view v)  {sharedpreferences pref  = getsharedpreferences ("data", mode_private); String name = pref.getstring ("name",  ""); int age = pref.getint ("age",  0); Boolean married = pref.getboolean ("married",  false); LOG.D ("mainactivity",  "name is "  + name); LOG.D ("mainactivity",  "age is "  + age); LOG.D ("mainactivity",  "married is "  + married);});} </pre></pre><p><p><span style="color: rgb(0, 0, 0); font-family:; font-size: 14pt; font-style: normal; font-variant: normal;"><span style="color: rgb(0, 0, 0); font-family: 黑体; font-size: 14pt; font-style: normal; font-variant: normal;"><span style="color: rgb(0, 0, 0); font-family:; font-size: 10pt; font-style: normal; font-variant: normal;"><span style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 10pt; font-style: normal; font-variant: normal;"><span style="color: rgb(0, 0, 0); font-family: 宋体; font-size: 10pt; font-style: normal; font-variant: normal;"></span></span></span></span></span></p></p><p><p><span style="color: rgb(0, 0, 0); font-family:; font-size: 14pt; font-style: normal; font-variant: normal;"><span style="color: rgb(0, 0, 0); font-family: 黑体; font-size: 14pt; font-style: normal; font-variant: normal;">3,sqlite<br></span></span></p></p><p><p>Android Persistence Technology</p></p></span>

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.