try { // Save File FileOutputStream fos = openFileOutput("test.txt", Context.MODE_WORLD_READABLE); String str = "<maintag>\r\n" + "<System>\r\n" + "<EcoServerIP>192.168.1.10</EcoServerIP>\r\n" + "<DataTestType>1</DataTestType>\r\n" + "</System>\r\n" + "</maintag>"; fos.write(str.getBytes()); fos.close(); Toast.makeText(EcoAgent.this, "input test", 0).show(); } catch(Exception e) { } |
File Read
try { // Load File
FileInputStream fis = openFileInput("test.txt"); byte[] data = new byte[fis.available()]; while(fis.read(data) != -1) {;} fis.close(); Toast.makeText(EcoAgent.this, (new String(data)), 0).show(); } catch(Exception e) { } |
'Programming & Tools > Android' 카테고리의 다른 글
[Android] your project contains errors please fix them before running your application (0) | 2012.03.23 |
---|---|
[Android] Static Library 만들기 (0) | 2011.05.27 |
[Android] "Failed to install xxxxxxx.apk on device 'M110axxxxx': timeout" (1) | 2011.04.07 |
[Android] Title Bar 없애는 방법 (0) | 2011.04.01 |
[Android] IP Address 가져오는 소스 예제 (0) | 2011.03.08 |