私はコードAはうまく動作しますが、私は内部に格納されたファイルを読み込む際に、コードBがうまく動作しない、私はコードにinputStream = new FileInputStream(mContext.getFilesDir()+"/hello_file");
ファイルからFileInputStreamを取得すると、なぜフォルダを追加する必要がありますか?
を使用する必要があり、私は、フォルダを追加する必要がありますhttps://developer.android.com/guide/topics/data/data-storage.html#filesInternal
で記事を読みましたストレージ ?
コードA
String FILENAME = "hello_file";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
コードB
InputStream inputStream = null;
int size = 0;
try {
inputStream = new FileInputStream("hello_file");
size=inputStream.available();
Utility.LogError("Size Html: "+size);
}catch (Exception e){
Utility.LogError("Error: Input"+e.getMessage());
}