에 볼 수 있습니다 경우
감사
편집
그것은 큰 문제입니다 밤은 내가 저장 디렉토리 얻기 위해 사용하는 샘플 코드 :
/**
* Check if external storage is built-in or removable.
*
* @return True if external storage is removable (like an SD card), false
* otherwise.
*/
@TargetApi(9)
public static boolean isExternalStorageRemovable() {
if (hasGingerbread()) {
return Environment.isExternalStorageRemovable();
}
return true;
}
/**
* Get the external app cache directory.
*
* @param context The context to use
* @return The external cache dir
*/
@TargetApi(8)
public static File getExternalCacheDir(Context context) {
if (hasFroyo()) {
return context.getExternalCacheDir();
}
// Before Froyo we need to construct the external cache dir ourselves
final String cacheDir = "/Android/data/" + context.getPackageName() + "/cache/";
return new File(Environment.getExternalStorageDirectory().getPath() + cacheDir);
}
/**
* Get a usable cache directory (external if available, internal otherwise).
*
* @param context The context to use
* @param uniqueName A unique directory name to append to the cache dir
* @return The cache dir
*/
public static File getDiskCacheDir(Context context, String uniqueName) {
// Check if media is mounted or storage is built-in, if so, try and use external cache dir
// otherwise use internal cache dir
final String cachePath =
Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
!isExternalStorageRemovable() ? getExternalCacheDir(context).getPath() :
context.getCacheDir().getPath();
return new File(cachePath + File.separator + uniqueName);
}
을 그리고 당신은 자신의 파일을 배치하는 경로가있어 ....
이제 설치시에 자산을 처음 실행할 때 해당 폴더로 복사하거나 필요에 따라 파일을 만들고 채워야합니다. 앱에서 애셋을 가져올 수 있습니다. 앱에서 앱을 만들거나 일부 서버에서 다운로드 할 수 있습니다.
EDIT1 :
public static boolean hasFroyo() {
// Can use static final constants like FROYO, declared in later versions
// of the OS since they are inlined at compile time. This is guaranteed behavior.
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
}
public static boolean hasGingerbread() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
}
당신이 그들을 필요 따라 달라집니다 폴더는 ... 안드로이드/데이터/your_package_name/캐시 + 아무것도 당신이 원하는에
및 진저 브레드와 프로 요에 사용되는 두 가지 기능을 할 것이다 에 대한. SD 카드에 외부에서 저장하면 사용자가 볼 수 있거나 조작 할 수 있습니다. 내부적으로 보관하면 안됩니다. 두 경우 모두 앱에 올바른 권한이있는 경우 읽고 쓸 수 있습니다. 귀하의 옵션은 다음과 같습니다. http://developer.android.com/guide/topics/data/data-storage.html –
My Java Project에서, 모든 txt 파일을 어디로 옮길 것입니까? PRIVATE/INTERNAL 폴더는 어디에 있습니까? –
http://developer.android.com/guide/topics/data/data-storage.html#filesInternal 프로그래밍 방식으로 액세스해야합니다. –