Compare a new line with the last line in a TXT file
Hello I have an App that uses the GPS to find your location, then it
writes the locaction to a txt file
try
{
OutputStreamWriter fout= new
OutputStreamWriter(openFileOutput("datosgps.txt",
Context.MODE_APPEND));
fout.append( latitude+longitude+"\n");
Intent intent = new Intent(getApplicationContext(), aviso.class);
startActivity(intent);
fout.close();
}
catch (Exception ex)
{
Log.e("Ficheros", "Error");
}
Inside the txt file I have this:
Latitud: 49.650 Longitud: 2.931 Latitud: 49.655 Longitud: 2.939 Latitud:
49.656 Longitud: 2.939 Latitud: 49.657 Longitud: 2.939 Latitud: 49.657
Longitud: 2.939
One below the other.
Every 2 minutes second, it write the NEW location, What can I do to check
if the NEW line is the SAME that the LAST line?
for example, I want it to read
Latitud: 49.656 Longitud: 2.939
and then write the new location
Latitud: 49.657 Longitud: 2.939
CHECK IF THEY ARE EQUALS
if not, do nothing
read the LAST
Latitud: 49.657 Longitud: 2.939
and the NEW location
Latitud: 49.657 Longitud: 2.939
IF are equal do something
Any suggestion will be apreciated
No comments:
Post a Comment