public boolean CertificateVersion()
{
String s_url = "버전이 있는 주소";
URL ver_url;
try {
ver_url = new URL(s_url);
HttpURLConnection http;
try {
http = (HttpURLConnection)ver_url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
StringBuffer buffer = new StringBuffer();
int c;
while((c=in.read()) != -1){
buffer.append((char)c);
}
String content = buffer.toString();//content 있는 값을 비교한다.
if(content.equals(version) == false)
{
{
Update();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return false;
}
public void Update()
{
File updater = new File("/sdcard/프로그램업데이터넣을곳/");
if(!updater.exists()) {
updater.mkdirs();
}
try {
URLConnection uc = new URL(업데이트 주소).openConnection();
InputStream in = uc.getInputStream();
int len=0;
byte[] buf = new byte[1024];
File updateFile=new File(updater + filename);
// 다운로드
FileOutputStream fos = new FileOutputStream(updateFile);
while((len=in.read(buf, 0, 1024)) != -1) {
total += len;
fos.write(buf, 0, len);
}
in.close();
fos.flush();
fos.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.i("fdin", e.getMessage());
}
Toast.makeText(Activity.this, "업데이트 파일을 실행해주세요, 위치 : " + updater + filename, Toast.LENGTH_LONG).show();
System.exit(0);
}
'프로그래밍!! > Android' 카테고리의 다른 글
| WebView에서 url이 로딩될 때 내부처리/외부처리 바꾸기 (0) | 2011/09/02 |
|---|---|
| 안드로이드에서 웹으로 데이터 넘기기. (0) | 2011/08/08 |
| 안드로이드에서 버전업 했을때 버전 확인하고 다운 받기 (0) | 2011/07/26 |
| 안드로이드에서 SharedPreferences(임시 저장 공간) 활용하기 (0) | 2011/07/26 |
| Android에서 자기 번호 가져오기 (0) | 2011/07/26 |






Recent Comment