zoukankan      html  css  js  c++  java
  • Android 数据回显

    public class EchoDataUtils {
    /**
    * 保存文件到手机内存
    * @param context
    * @param number
    * @param psw
    * @return
    */
    public static boolean SaveUserInfo(Context context, String number,
    String psw) {
    try {
    File fileDir = context.getFilesDir();
    File f = new File(fileDir, "data.txt");
    FileOutputStream fos;

    fos = new FileOutputStream(f);

    String data = number + "##" + psw;
    fos.write(data.getBytes());
    fos.flush();
    fos.close();
    return true;
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return false;
    }
    /**
    * 从手机内存读取
    * @param context
    * @return
    */
    public static Map<String, String> GetUserInfo(Context context) {

    try {
    File fileDir = context.getFilesDir();
    File f = new File(fileDir, "data.txt");
    FileInputStream fis;
    fis = new FileInputStream(f);
    BufferedReader reader = new BufferedReader(new InputStreamReader(
    fis));
    String text = reader.readLine();
    if (!text.isEmpty()) {
    String split[] = text.split("##");
    Map<String, String> userInfoMap = new HashMap<String, String>();
    userInfoMap.put("number", split[0]);
    userInfoMap.put("psw", split[1]);
    return userInfoMap;
    }
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return null;

    }
    }
  • 相关阅读:
    SmartJS 系列规划分享和背景介绍
    SmartJS 第一期(0.1)发布
    让文档和Demo生成更加简单和强大
    SmartDoc(YUIDoc) 注释编写
    smartjs
    smartjs
    smartjs 0.3 DataManager 发布&介绍
    smartjs 0.2 OOP讲解
    smartjs 0.2 OOP讲解
    smartjs 0.2发布
  • 原文地址:https://www.cnblogs.com/la66/p/11539894.html
Copyright © 2011-2022 走看看