728x90
반응형
<Manifests>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider" />
</provider>
<xml - file_provider>
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<!--
여기에 쓰이는 경로는 아래의 코드를 통해서 바로 경로를 가져 오기 위함.?
/*
<files-path/> –> Context.getFilesDir()
<cache-path/> –> Context.getCacheDir()
<external-path/> –> Environment.getExternalStorageDirectory()
<external-files-path/> –> Context.getExternalFilesDir(String)
<external-cache-path/> –> Context.getExternalCacheDir()
<external-media-path/> –> Context.getExternalMediaDirs()*/ -->
<external-path
name="external"
path="." />
<cache-path
name="cache"
path="." />
<external-cache-path
name="external_cache"
path="." />
<files-path
name="files"
path="." />
<external-files-path
name="external_files"
path="." />
</paths>
경로 보는 소스
void printPath(){
/*
https://crazykim2.tistory.com/488
https://easy-coding.tistory.com/26#google_vignette
<files-path/> –> Context.getFilesDir()
<cache-path/> –> Context.getCacheDir()
<external-path/> –> Environment.getExternalStorageDirectory()
<external-files-path/> –> Context.getExternalFilesDir(String)
<external-cache-path/> –> Context.getExternalCacheDir()
<external-media-path/> –> Context.getExternalMediaDirs()*/
/*
* 디렉토리 만들기 - 디렉토리만 만들기하면, 생성되지 않는다, 파일 생성시 디렉토리를 체크후 만들도록 한다.
* */
String getFilesDir = "getFilesDir"+ getFilesDir();
String getCacheDir = "getCacheDir"+ getCacheDir();
String getExternalStorageDirectory = "getExternalStorageDirectory"+ Environment.getExternalStorageDirectory();
String getExternalFilesDir = "getExternalFilesDir"+ getExternalFilesDir(null);
String getExternalCacheDir = "getExternalCacheDir"+ getExternalCacheDir();
String getExternalMediaDirs = "getExternalCacheDir"+ getExternalMediaDirs();
Log.d("WLOG",getFilesDir);
Log.d("WLOG",getCacheDir);
Log.d("WLOG",getExternalStorageDirectory);
Log.d("WLOG",getExternalFilesDir);
Log.d("WLOG",getExternalCacheDir);
Log.d("WLOG",getExternalMediaDirs);
}
디렉토리 만들기
public void mkDirFile(){
File checkDir = new File(Environment.getExternalStorageDirectory()+"/WGTEST/");
if(!checkDir.exists()){
boolean result = checkDir.mkdirs();
Log.d("WLOG","생성완료"+"result "+result+"path => "+checkDir.getAbsolutePath());
}else{
Log.d("WLOG","이미 디렉토리가 존재 => "+checkDir.getAbsolutePath());
}
}
https://crazykim2.tistory.com/488
728x90
반응형
'Android' 카테고리의 다른 글
모듈 만들기 (0) | 2023.01.30 |
---|---|
android 아래 버튼 ( Navigation Bar ) 숨기기 (0) | 2023.01.05 |
안드로이드 UI 명칭 ( 수집중 ) (0) | 2022.12.28 |
Android _ Pixel GridView ( feat. Canvas ) (0) | 2022.12.13 |
android EditText InputFilter (0) | 2022.10.25 |