안드로이드 파일입출력 질문 드립니다~

mmx822의 이미지


일단 제가 하고 싶은 것은요..

c:\input.txt 파일을 불러서.. 그것을 단순히 EditText 박스에 뿌려주고 싶습니다..

그래서 저는


protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.act1);
  try {
   FileInputStream fis = new FileInputStream("c:\\input.txt");
   BufferedReader br = new BufferedReader(new InputStreamReader(fis));
   a = br.readLine().toString();
   EditText i = (EditText) findViewById(R.id.editText1);
   i.setText(a);
 
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 
 }

이렇게 작성을 해봤는데요.. 실행은 되는데.. id editText1 에 뿌려지질 않습니다..

아참 input.txt 파일의 내용은 간단합니다.. 그냥 "나는 안드로이드" 이거거든요...ㅜㅜ

제가 자바 파일 입출력부분이 많이 약해서 그런거라고 생각하지만.. 너무 해결이 안되서 이렇게 도움 요청드립니당~~

꼭 좀 도와주세요~

Ohyung의 이미지

FileInputStream fis = new FileInputStream("c:\\input.txt");
위의 직접 엑세스가 안먹히는것으로 알고 있습니다.
sdCard위치로 파일을 이동하신후 엑세스 해보세요~

안드로이드 DCIM의 경우
String path = Environment.getExternalStorageDirectory().toString();
String saveDirectory = "/DCIM/";
File file = new File(path, saveDirectory + "test1.jpg");
이런식으로 쓰시면 됩니다.