을지초 손재용 님이 쓰신 글 :
: 안녕하세요.
: 윈도우 pc에서 미디어플레이어 작동 코드
: MediaPlayer1->FileName="c:/a/1.mp3";
: MediaPlayer1->Open();
: MediaPlayer1->Play();
:
:
: 파일 불러오기 코드...
:
: Memo1->Lines->Add("c:/a/first.txt");
:
:
: 위의 두 가지 경우 절대경로로 하면...
: 윈도우에서 음악재생이나 파일불러오는게 되는데
:
: 안드로이드로 하면 경로가 어떻게 해야 하는지 좀 여쭈어봅니다.
:
: 검색해서 봤는데 "SD 카드" 이런식으로 경로가 되서 한글이니 , 공백(스페이스)가 있으면
: 안되는게 아닌가 하는 생각도 듭니다.
: 셈플코드 있음 더 감사하겠습니다.
:
: 감사합니다.
iOS 와 Android 에서는, 각 앱 마다 고유 Document 폴더가 있습니다.
( 보안때문에, 다른 앱에 관련된 폴더는 접근이 제한됩니다.)
아래 셈플코드는, 해당 앱에 할당된 다큐먼트 폴더 경로를 구해서, 그 곳에 데이타를 저장하는 코드입니다.
(현재 제가 근무 중인 회사 내부용 안드로이드 앱에서 사용 중 인 코드입니다.)
>>>>>>>>>>>>>> 셈플코드 <<<<<<<<<<<<<
String stDocPath, stFileName, stTarget ;
stDocPath = IncludeTrailingPathDelimiter(System::Ioutils::TPath::GetDocumentsPath()) ;
stFileName = "myFileName" ;
stTarget = stDocPath + stFileName ;
this->MemoList->Lines->SaveToFile(stTarget) ;
>>>>>>>>>>>>>> 셈플코드 <<<<<<<<<<<<<
아래는 각 폴더 경로를 구하는 Function 리스트 입니다.
위의 코드 중,
stDocPath = IncludeTrailingPathDelimiter(System::Ioutils::TPath::GetDocumentsPath()) ;
에서 GetDocumentsPath() 대신 GetExternalMusicDir() 을 대입해서, 테스트 해 보세요.
아래는, 폴더 경로 구하는 function 리스트입니다.
function GetFilesDir: string;
function GetCacheDir: string;
function GetLibraryPath: string;
// File Locations in External memory. (Accessible only to the program, but easily
// readable mounting the external storage as a drive in a computer.
// Files written here are deleted when uninstalling the application.)
function GetExternalFilesDir: string;
function GetExternalCacheDir: string;
function GetExternalPicturesDir: string;
function GetExternalCameraDir: string;
function GetExternalDownloadsDir: string;
function GetExternalMoviesDir: string;
function GetExternalMusicDir: string; <<<<<<<<< 외장 SD Card의 뮤직 폴더에서 mp3 파일을 가져올 경우...
function GetExternalAlarmsDir: string;
function GetExternalRingtonesDir: string;
// File Locations in External memory. (Accessible to all programs, easily
// readable mounting the external storage as a drive in a computer.
// Files written here are preserved when uninstalling the application.)
function GetSharedFilesDir: string;
function GetSharedPicturesDir: string;
function GetSharedCameraDir: string;
function GetSharedDownloadsDir: string;
function GetSharedMoviesDir: string;
function GetSharedMusicDir: string;
function GetSharedAlarmsDir: string;
function GetSharedRingtonesDir: string;
이 외에 아래와 같은 function 도 있는거 같습니다만, 사용해 보지는 않았습니다.
GetTempPath
GetPublicPath
GetCameraPath
GetMusicPath
GetDownloadsPath
참고로, 개발하시는 앱의 권한을 설정하는 부분에서, Read external storage 가 true 인지 확인해 주시면 됩니다. 기본으로 true 가 설정되어 있을 겁니다.
( Project >> Options >> Application >> Uses Permission >> Dangerous(runtime user approval) >> Read external storage )
|