3.19

文件存储


用到的快捷键

alt+shift+上下, 整行移动位置
ctrl + alt +t ,surround with

checkbox

判断checkbox是否被勾选:checkboxobject.isChecked() :boolean
判断字符串是否为空TextUtils.isEmpty(StringObject) :boolean

存储文件

不能直接写File file = new File("XXX.txt"),因为这是将数据保存在了linux的根目录“/” 下, 而app不可能取得这样的权限。每个app可以将数据保存的到自己独自的文件夹下。如File file = new File("/data/data/com.mqy.app/XXX.txt")整个写法的例子

File file = new File("/data/data/com.example.mqy.myapplication/save.txt"); 
try { OutputStream out = newFileOutputStream(file); 
    String value = username + password; 
    out.write(value.getBytes());
    out.close(); 
}  
catch (Exception e) { 
    e.printStackTrace(); 
}

更多的内容在java i/o流里有

你可能感兴趣的:(3.19)