Android Persistence Technology
Last Update:2015-10-16
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>