Android通过反射打造可以存储任何对象的万能SharedPreferences
来源:互联网 发布:php图片用什么打开 编辑:程序博客网 时间:2024/06/06 03:30
我们通常使用SharedPreferences存储一些需要保存在本地,但又不至于存储在数据库里的一些数据,一般我们用它来存储一些用户名,密码等数据是非常方便的,那么如果我们想要存储的信息有10几条,我们就得写10几行重复的代码把他们存进去,取出来的时候还得写10几行代码将他们一条一条取出来,那么有没有什么办法可以只需要一行代码就可以将他们存进去,一行代码就将他们取出来?答案是有的,这篇文章我们就介绍如何通过反射来实现。
1.将我们想要保存的数据封装成一个实体类 Person.java 其中属性我们都用Public来修饰
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a>
来自CODE的代码片Person.java
2.通过反射,将Person类中的属性取出来
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a><a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a><a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a><a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a><a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a><a target=_blank id="L17" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a><a target=_blank id="L18" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a><a target=_blank id="L19" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a><a target=_blank id="L20" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a>
来自CODE的代码片SharedPreferencesUtils.java
我们先来测试一下属性有没有被取出来,我们在MainActivity.java中添加如下代码进行测试
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a><a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a>
来自CODE的代码片MainActivity.java
我们来看一下Log打印的信息
我们可以看到,Person中的属性我们都已经拿到了
3.将对象存储到SharedPreferences中
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a><a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a><a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a><a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a><a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a><a target=_blank id="L17" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a><a target=_blank id="L18" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a><a target=_blank id="L19" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a><a target=_blank id="L20" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a><a target=_blank id="L21" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a><a target=_blank id="L22" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a><a target=_blank id="L23" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a><a target=_blank id="L24" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a><a target=_blank id="L25" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a><a target=_blank id="L26" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a><a target=_blank id="L27" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a><a target=_blank id="L28" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a><a target=_blank id="L29" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a><a target=_blank id="L30" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a><a target=_blank id="L31" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a><a target=_blank id="L32" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a><a target=_blank id="L33" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a><a target=_blank id="L34" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;"> 34</a><a target=_blank id="L35" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;"> 35</a><a target=_blank id="L36" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;"> 36</a>
来自CODE的代码片SharedPreferencesUtils.java
4.将对象从SharedPreferences中取出来
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a><a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a><a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a><a target=_blank id="L15" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L15" rel="#L15" style="color: rgb(102, 102, 102); text-decoration: none;"> 15</a><a target=_blank id="L16" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L16" rel="#L16" style="color: rgb(102, 102, 102); text-decoration: none;"> 16</a><a target=_blank id="L17" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L17" rel="#L17" style="color: rgb(102, 102, 102); text-decoration: none;"> 17</a><a target=_blank id="L18" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L18" rel="#L18" style="color: rgb(102, 102, 102); text-decoration: none;"> 18</a><a target=_blank id="L19" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L19" rel="#L19" style="color: rgb(102, 102, 102); text-decoration: none;"> 19</a><a target=_blank id="L20" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L20" rel="#L20" style="color: rgb(102, 102, 102); text-decoration: none;"> 20</a><a target=_blank id="L21" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L21" rel="#L21" style="color: rgb(102, 102, 102); text-decoration: none;"> 21</a><a target=_blank id="L22" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L22" rel="#L22" style="color: rgb(102, 102, 102); text-decoration: none;"> 22</a><a target=_blank id="L23" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L23" rel="#L23" style="color: rgb(102, 102, 102); text-decoration: none;"> 23</a><a target=_blank id="L24" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L24" rel="#L24" style="color: rgb(102, 102, 102); text-decoration: none;"> 24</a><a target=_blank id="L25" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L25" rel="#L25" style="color: rgb(102, 102, 102); text-decoration: none;"> 25</a><a target=_blank id="L26" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L26" rel="#L26" style="color: rgb(102, 102, 102); text-decoration: none;"> 26</a><a target=_blank id="L27" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L27" rel="#L27" style="color: rgb(102, 102, 102); text-decoration: none;"> 27</a><a target=_blank id="L28" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L28" rel="#L28" style="color: rgb(102, 102, 102); text-decoration: none;"> 28</a><a target=_blank id="L29" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L29" rel="#L29" style="color: rgb(102, 102, 102); text-decoration: none;"> 29</a><a target=_blank id="L30" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L30" rel="#L30" style="color: rgb(102, 102, 102); text-decoration: none;"> 30</a><a target=_blank id="L31" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L31" rel="#L31" style="color: rgb(102, 102, 102); text-decoration: none;"> 31</a><a target=_blank id="L32" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L32" rel="#L32" style="color: rgb(102, 102, 102); text-decoration: none;"> 32</a><a target=_blank id="L33" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L33" rel="#L33" style="color: rgb(102, 102, 102); text-decoration: none;"> 33</a><a target=_blank id="L34" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L34" rel="#L34" style="color: rgb(102, 102, 102); text-decoration: none;"> 34</a><a target=_blank id="L35" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L35" rel="#L35" style="color: rgb(102, 102, 102); text-decoration: none;"> 35</a><a target=_blank id="L36" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L36" rel="#L36" style="color: rgb(102, 102, 102); text-decoration: none;"> 36</a><a target=_blank id="L37" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L37" rel="#L37" style="color: rgb(102, 102, 102); text-decoration: none;"> 37</a><a target=_blank id="L38" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L38" rel="#L38" style="color: rgb(102, 102, 102); text-decoration: none;"> 38</a><a target=_blank id="L39" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L39" rel="#L39" style="color: rgb(102, 102, 102); text-decoration: none;"> 39</a>
来自CODE的代码片SharedPreferencesUtils.java
5.我们来测试一下,修改MainAcitvity.java中的代码
<a target=_blank id="L1" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a><a target=_blank id="L2" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a><a target=_blank id="L3" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a><a target=_blank id="L4" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a><a target=_blank id="L5" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a><a target=_blank id="L6" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a><a target=_blank id="L7" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a><a target=_blank id="L8" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a><a target=_blank id="L9" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a><a target=_blank id="L10" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a><a target=_blank id="L11" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L11" rel="#L11" style="color: rgb(102, 102, 102); text-decoration: none;"> 11</a><a target=_blank id="L12" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L12" rel="#L12" style="color: rgb(102, 102, 102); text-decoration: none;"> 12</a><a target=_blank id="L13" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L13" rel="#L13" style="color: rgb(102, 102, 102); text-decoration: none;"> 13</a><a target=_blank id="L14" href="http://blog.csdn.net/nugongahou110/article/details/46913461#L14" rel="#L14" style="color: rgb(102, 102, 102); text-decoration: none;"> 14</a>
来自CODE的代码片MainActivity.java
我们看一下Log中打印的savedPerson的信息
0 0
- Android通过反射打造可以存储任何对象的万能SharedPreferences
- Android通过反射打造可以存储任何对象的万能SharedPreferences
- android中通过SharedPreferences进行对象的存储
- android中通过SharedPreferences进行对象的存储
- android中通过SharedPreferences进行对象的存储
- 反射可以通过FieldInfo.SetValue设置任何字段的值
- android SharedPreferences 存储对象
- android SharedPreferences 存储对象
- android SharedPreferences 存储对象
- android SharedPreferences 存储对象
- android打造万能的适配器
- Android SharedPreferences 存储复杂对象
- Android SharedPreferences 存储复杂对象
- Kotlin 封装万能SharedPreferences存取任何类型
- Android的SharedPreferences存储
- Android的SharedPreferences存储
- 使用Vitamio打造自己的Android万能播放器——一个系列,可以参考下
- SharedPreferences 存储复杂的对象
- 小菜鸟的xmpp(一)openfire安装 status 一直stop 打开不了
- How to run application in Qt as administrator?
- 并没有那个艰难,但也并没有那么简单
- 适配器模式
- ImageView 长按保存
- Android通过反射打造可以存储任何对象的万能SharedPreferences
- POJ1094 Sorting It All Out 拓扑排序(深搜)
- 收藏网站56
- 物联网的发展前途
- Cocoa深入学习:NSOperationQueue、NSRunLoop和线程安全
- 《深入浅出struts2》--第三章,动作与结果
- ZOJ3690Choosing number
- hive-0.11.0安装方法详解
- POJ 1944:Fiber Communications