简体   繁体   English

写入/读取然后保存文本文件Basic4Android

[英]Write/Read then Save text file Basic4Android

I'm creating an application on Basic4android that collects GPS coordinates and equipment deficiencies in a dropdown list (Spinner). 我正在Basic4android上创建一个应用程序,该应用程序在下拉列表(“旋转器”)中收集GPS坐标和设备缺陷。 The GPS coordinates consists of latitude and longitude shows up on a label field when GPS is ON and the deficiencies shows up under a Spinner field (eg dropdown of "Broken cross arm", "Broken Insulator","Rusty Structure"). GPS开启时,GPS坐标由纬度和经度组成,而标签字段中显示,而Spinner字段中则显示缺陷(例如,“横臂折断”,“绝缘子折断”,“生锈的结构”下拉列表)。 I was able to get all that done and create a "Submit" button that should copy the three fields (Longitude, Latitude and deficiencies) into a text file. 我能够完成所有工作,并创建一个“提交”按钮,该按钮应将三个字段(经度,纬度和不足)复制到文本文件中。 Any idea how to store these fields everytime I press submit? 知道我每次按提交时如何存储这些字段吗? I will be using this application for inspection when I walk by a transmission tower, I will record the coordinates and the obvious deficiency into a file on android. 当我走过输电塔时,将使用此应用程序进行检查,并将坐标和明显不足之处记录到android文件中。

Thank you, 谢谢,

Eli

There are some solutions. 有一些解决方案。 one of them is writhing a list file .add a character as delimiter between Longitude, Latitude and deficiencies. 其中之一是扭曲列表文件。添加一个字符作为经度,纬度和缺陷之间的分隔符。

declare list in global section 在全局部分中声明列表

 Dim list1 as list

initialize list on create activity event 在创建活动事件上初始化列表

 List1.Initialize

On submit button click 在提交按钮上单击

newstring=longt &"|" &lat &"|"& defi 
If File.Exists (File.DirInternal & "/","Log.txt") Then
List1 = File.ReadList (File.DirInternal & "/","Log.txt")
end if
List1.add(newstring)
File.Writelist(File.DirInternal & "/","Log.txt",List1)

You can split every line int to seperated Longitude, Latitude and deficiencies later when you need. 以后需要时,您可以将每行int拆分为单独的经度,纬度和不足。

There are several ways to do it. 有几种方法可以做到这一点。 The simplest is to add the values to a Map and use File.WriteMap / ReadMap. 最简单的方法是将值添加到Map并使用File.WriteMap / ReadMap。

See this tutorial: http://www.basic4ppc.com/android/forum/threads/6690/#content 参见本教程: http : //www.basic4ppc.com/android/forum/threads/6690/#content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM