I am a beginner in android programming. My Graduate project is about tracking a mobile device and i need the code to save the location( Without using GPS) as a text file. Someone suggest me the codes for doing that. It will be a great help for me.
Asked
Active
Viewed 1,176 times
5
-
2Please search before asking a question, theres already answer for this available http://stackoverflow.com/questions/1756296/android-writing-logs-to-text-file http://stackoverflow.com/questions/5844579/how-to-write-to-an-external-text-file-in-android http://stackoverflow.com/questions/4580683/android-java-writing-text-file-to-sd-card – Ruuhkis Mar 16 '12 at 08:36
-
@Ruuhkis Thank u. But my project needs to save a txt file with network location details. Kindly help me. – Midhun Sivaraj Mar 16 '12 at 08:40
-
You can easily save the network details on text file just like you can print it out. see below – Ruuhkis Mar 16 '12 at 09:38
2 Answers
2
Try this.
locationManagerNetwork = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location location2 = locationManagerNetwork
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location2 != null) {
String message = String
.format("Yout location : \n Longitude: %1$s \n Latitude: %2$s",
location2.getLongitude(), location2.getLatitude());
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG)
.show();
//use here file writer if you want to write the coordinates in a text file
}
for writing sd card
File sdcard = Environment.getExternalStorageDirectory();
File f = new File(sdcard, "/yourfile");
if(!f.exsist()){
f.createNewFile();
//Use outwriter here, outputstream search how to write into a file in java code
}

Tugrul
- 1,760
- 4
- 24
- 39
-1
only way to do that is to play with telephony manager and see what kind of information you can get about cell tower or network. Every network tower have unique id to it and from that you might be able to get an approx estimation depending upon signal strength and stuff of person's location.
I bet it'll be fun and tricky business.

Mayank
- 8,777
- 4
- 35
- 60
-
Is there any way to find the approx network location using code. I have tried many codes. Nothing works. – Midhun Sivaraj Mar 16 '12 at 08:43
-
Many codes and methods described by stackoverflow users. Please help me bro. – Midhun Sivaraj Mar 16 '12 at 08:51
-
-
I want to take the Service Provider Network Location and save it to the SD card as a .txt file. – Midhun Sivaraj Mar 16 '12 at 08:58
-
can you post some example data you get from telephony manager, from there we might be able to figure out something – Mayank Mar 16 '12 at 09:00
-
check this post, https://groups.google.com/forum/?fromgroups#!topic/android-developers/ASVpv7RbLL8 – Mayank Mar 16 '12 at 09:04