Write/Read then Save text file Basic4Android

8.2k views Asked by At

I'm creating an application on Basic4android that collects GPS coordinates and equipment deficiencies in a dropdown list (Spinner). 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 (e.g. dropdown of "Broken cross arm", "Broken Insulator","Rusty Structure"). 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.

Thank you,

Eli

2

There are 2 answers

0
Erel On BEST ANSWER

There are several ways to do it. The simplest is to add the values to a Map and use File.WriteMap / ReadMap.

See this tutorial: http://www.basic4ppc.com/android/forum/threads/6690/#content

0
Shahram Banazadeh On

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.