Android 数据回显
Posted la66
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
以上是关于Android 数据回显的主要内容,如果未能解决你的问题,请参考以下文章