WEB开发网
开发学院手机开发Android 开发 Android系列只androidGooglemap小应用 阅读

Android系列只androidGooglemap小应用

 2010-08-19 14:32:00 来源:WEB开发网   
核心提示:catch (Exception e) {39 throw new RuntimeException(e);40 }41 return messages;42 }POJO类转化成XML字符串1 public static String writeXml(List data){ 2 XmlSerializer seria
catch (Exception e) {39 throw new RuntimeException(e);40 }41 return messages;42 }

POJO类转化成XML字符串

1 public static String writeXml(List data){ 2 XmlSerializer serializer = Xml.newSerializer(); 3 StringWriter writer = new StringWriter(); 4 try{ 5 serializer.setOutput(writer); 6 // 7 serializer.startDocument("UTF-8",true); 8 serializer.startTag("","Locations"); 9 10 for(int i=0;i< }42 RuntimeException(e);41 new throw {40 e)39 catch(Exception }38 writer.toString();37 return serializer.endDocument();36 serializer.endTag(??,?Locations?);35 34 33 }32 31 serializer.endTag(??,?Location?);30 29 serializer.endTag(??,?longitude?);28 serializer.text(String.valueOf(data.get(i).getLocation_longitude()));27 serializer.startTag(??,?longitude?);26 25 serializer.endTag(??,?latitude?);24 serializer.text(String.valueOf(data.get(i).getLocation_latitude()));23 serializer.startTag(??,?latitude?);22 21 serializer.endTag(??,?ring?);20 serializer.text(data.get(i).getLocation_ring());19 serializer.startTag(??,?ring?);18 17 serializer.endTag(??,?id?);16 serializer.text(data.get(i).getLocation_Id());15 serializer.startTag(??,?id?);14 13 serializer.startTag(??,?Location?);12>

有了XML的字符串后只要将它存储起来就行,需要使用是再读取

以下是存储和读取文件函数。由于SD卡的读取还需要判断SD卡的状态,函数比较长,就贴存手机内存的代码

反正大同小异

1 public static InputStream readInternalFileInputStream(Context context,String fileName){ 2 /** 3 * 读取手机内存文件 4 * */ 5 6 try{ 7 FileInputStream fis = context.openFileInput(fileName); 8 9 return fis;10 }catch(Exception e){11 return null;12 }13 14 }15 public static String readInternalFile(Context context,String fileName){16 /**17 * 读取手机内存文件18 * */19 20 try{21 byte[] buffer = new byte[512];22 int read =0;23 StringBuffer stringbuffer = new

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android 系列 androidGooglemap

编辑录入:coldstar [复制链接] [打 印]
赞助商链接