파일을 여는 데 약간의 문제가 있습니다. 잘 난 이미 파일이 어디 있는지 알고 절대 경로를 사용했지만 여전히 파일 (파일을 찾을 수 없습니다) 나는 문제가 장치가 파일을하지 않았 음을 추측파일을 찾을 수 없습니다
public void ReadFromFile() throws FileNotFoundException
{
/** Read the contents of the given file. */
String SourceID = new String();
String LogicalID = new String();
File fileDir = getFilesDir();
String s = new String();
s+=fileDir.getAbsolutePath()+"/Nodes.txt";
Scanner scanner = new Scanner(new FileInputStream(s));
try
{
while (scanner.hasNextLine())
{
SourceID = scanner.nextLine();
LogicalID = scanner.nextLine();
String ss = new String();
ss+=" ----------------> "+SourceID+" "+LogicalID+" ";
Log.v(TAG, ss);
ListaNodesSTART.add(new NodesToStart(SourceID,LogicalID));
}
}catch(Exception ee){//Log.v(TAG, "Could not read the file");
ERROR.setText("Could Not Read file Nodes.txt");
ErRorLog.setText("Could Not Read file Nodes.txt");}
finally{scanner.close(); }
}
을 열 질수 있지만, 어떻게 앱을 시작할 때 업로드 할 수 있습니까?
미리 감사드립니다.
당신이 당신의 manifest.xml에이 권한을 준 한 일은 사용 - 권한 안드로이드 : 이름 = "android.permission.WRITE_EXTERNAL_STORAGE"/> – Aerrow
네 하지만 어쨌든 그것을 찾지 못했습니다 : 06-04 16 : 50 : 36.674 : W/System.err (24897) : java.io.FileNotFoundException : /data/data/neves.ProjectNodes/files/Nodes.txt (No such such 파일 또는 디렉토리) –