나는 android app에서 일하고 있는데, 파일의 이름을 바꾸고 싶다.내 파일의 이름을 변경하지 않는 이유는 무엇입니까?
File f = adapter.getItem(i);
File file = new File(f.getAbsolutePath(), "helloworld");
if (f.renameTo(file)) {
Toast.makeText(getActivity(), "done", Toast.LENGTH_LONG).show();
}
솔루션 큰 감사를 @SD에 (주석 참조)
File f = adapter.getItem(i);
File file = new File(f.getParent(), "helloworld");
if (f.renameTo(file)) {
Toast.makeText(getActivity(), "done", Toast.LENGTH_LONG).show();
}
이 문제의 본질은 무엇이며 그것을 던져 않습니다 추가 할 수있는 권한이
는이 게시물 "입니다..? 예외가 발생하거나 그냥 false를 반환합니까? –
'f.getAbsolutePath()'를'f.getParent()'로 대체하십시오. –
매력처럼 작동했습니다! 고마워요! – user2351234