Android获取到SharedPreferences对象sp后,保存数据正确的逻辑是( )。
A: sp.edit();
B: sp.edit().putString(“name”,”zhangsan”).apply();
C: sp.edit().putString(“name”,”zhangsan”);
D: sp.edit().put(“name”,”zhangsan”).apply();
A: sp.edit();
B: sp.edit().putString(“name”,”zhangsan”).apply();
C: sp.edit().putString(“name”,”zhangsan”);
D: sp.edit().put(“name”,”zhangsan”).apply();
举一反三
- 存储数据 SharedPreferences sp = getSharedPreferences("data",MODE_PRIVATE); Editor editor = sp.edit(); editor.putString("name", "传智播客"); editor.putInt("age", 8); editor.commit(); 以上程序把name、age等信息保存到一个文件名为data.txt的文件中
- Android获取到SharedPreferences对象sp后,保存数据正确的逻辑是( )。
- Android 中获取到sp对象 SharedPreferences sp = new SharedPreferences(); ()
- 声明一个对象,给它加上name属性和show方法显示其name值,以下代码中正确的是() A: varobj=[name:"zhangsan",show:function(){alert(name);}]; B: varobj=,name:"zhangsan",show:”alert(this.name)”-; C: varobj={name:"zhangsan",show:function(){alert(name);}}; D: varobj={name:"zhangsan",show:function(){alert(this.name);}};
- 以下关于字符串变量的声明不正确的是? A: var myText = "my name is zhangsan"; B: var myText = 'my name is zhangsan'; C: var myText = 'my name is zhangsan"; D: var myText = "my name is\t zhangsan";