forked from aanchal298/location
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateFile.java
69 lines (58 loc) · 1.83 KB
/
UpdateFile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.example.location;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import android.app.Activity;
import android.app.Fragment.SavedState;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class UpdateFile extends Activity{
public static String job2,job1;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Toast.makeText(getApplicationContext(),"delhi", Toast.LENGTH_SHORT).show();
String combi="$\n"+JobList.job1+"\n"+ GeocodingActivity.aString+"\n"+ GeocodingActivity.bb;
File externalStorageDir = Environment.getExternalStorageDirectory();
File myFile = new File(externalStorageDir , "locationplus.txt");
if(!myFile.exists())
{
try {
myFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String fileName="locationplus.txt";
FileOutputStream str = null;
try {
//str.write(combi.getBytes());
BufferedReader br3 = new BufferedReader(new FileReader(new File(Environment.getExternalStorageDirectory(),"locationplus.txt")));
String line,fullFile = combi;
while((line = br3.readLine() )!=null)
{
fullFile+="\n"+line;
}
str = new FileOutputStream(new File(Environment.getExternalStorageDirectory() + "/"+ fileName));
str.write(fullFile.getBytes());
} catch (Exception e) {
} finally {
try {
str.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}