Androidのmkdirs()がfalseを返しています。私はあなたに似たような質問をした別の回答を読んでいます。あなたはEnvironment.getExternalについて何か言及しました...とにかく私はドロイドXでAndroid 2.2を実行しています。sdカードがマウントされていて、isreadableとiswritableの両方の戻り値がtrueを返します。ここに私のコードは...Android mkdirs()がfalseを返す
public void writeToExternalStoragePublic(String filename, byte[] content) {
// API Level 7 or lower, use getExternalStorageDirectory()
// to open a File that represents the root of the external
// storage, but writing to root is not recommended, and instead
// application should write to application-specific directory, as shown below.
String packageName = this.getPackageName();
Toast.makeText(this, packageName, 1000).show();
String path = "/Android/data/";// + packageName + "/files/";
if (isExternalStorageAvailable() &&
!isExternalStorageReadOnly()) {
try {
File file = new File(path, filename);
file.mkdirs();
file.mkd
Toast.makeText(this, "Made Dirs = " + file.mkdirs(), 1000).show();
Toast.makeText(this, "Made Dir = " + file.mkdir(), 1000).show();
FileOutputStream fos = new FileOutputStream(file);
fos.write(content);
fos.close();
Toast.makeText(this, "success", 1000).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(this, "fnf", 1000).show();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "io", 1000).show();
} catch (SecurityException e) {
Toast.makeText(this, "security", 1000).show();
}
}
}
ありがとうございました。私はmkdirsにそれを得ることができる方法を知っているなら、私はそれを感謝します。ありがとうございました。
このコードは実際には他の人の例であり、私はそれを機能させるようにしています。
http://www.ibm.com/developerworks/xml/library/x-androidstorage/index.html
D-RAN
実際、これは有効なパスではありません。 http://developer.android.com/guide/topics/data/data-storage.html#AccessingExtFilesを参照してください。古いAPIバージョンではgetExternalStorageDirectory()が推奨されていますが、複数のストレージボリュームを持つデバイス( "内部/外部SDなど) –