私のアプリでは、アプリケーションの内部ストレージ ( /data/data/[pkgname]/x/y/z...
.
失敗したコードは次のとおりです。
File clusterDirectory = new File(MyApplication.getContext().getFilesDir(), "store");
File baseDirectory = new File(clusterDirectory, "data");
if (!baseDirectory.exists()) {
if (!baseDirectory.mkdirs()) {
throw new RuntimeException("Can't create the directory: " + baseDirectory);
}
}
次のパスを作成しようとすると、私のコードは例外をスローしています:
java.lang.RuntimeException: Can't create the directory: /data/data/my.app.pkgname/files/store/data
私のマニフェストは、<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
この目的には必要ない場合でも、パーミッションを指定しています (Google Maps Android API v2 により、実際には私のアプリには必要です)。
新しい携帯電話だけでなく古い携帯電話でもこの例外が発生するため、携帯電話とは関係がないようです (最後のクラッシュ レポートは Android 4.3 を搭載した Nexus 4 です)。
私の推測では、ディレクトリ/data/data/my.app.pkgname
はそもそも存在しませんが、 mkdirs() は権限の問題のためにディレクトリを作成できません。それは可能でしょうか?
ヒントはありますか?
ありがとう