๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT-Engineering/Android

์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค - ์•ฑ๋ณ„ ๋””๋ ‰ํ† ๋ฆฌ ์‚ฌ์šฉํ•˜๊ธฐ(feat. Device File Explorer)

by ๐Ÿงž‍โ™‚๏ธ 2020. 3. 9.
๋ฐ˜์‘ํ˜•

๋ถ€์ œ: Device File Explorer์—์„œ Permission denied ๋ฌธ์ œ ํ•ด๊ฒฐ๊ธฐ

 

์•ˆ๋“œ๋กœ์ด๋“œ ์ŠคํŠœ๋””์˜ค ๊ฐœ๋ฐœ์‹œ ์—๋ฎฌ๋ ˆ์ดํ„ฐ์—์„œ ์•ฑ๋ณ„ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ผ์„ ์˜ฌ๋ฆฌ๊ณ  ๋ถˆ๋Ÿฌ๋“ค์ด๋Š” ๊ฒฝ์šฐ

ํƒ์ƒ‰๊ธฐ ๋ ˆ๋ฒจ์—์„œ ํŒŒ์ผ ์—…๋กœ๋“œ๋ฅผ ํ•˜๊ณ  ์ฝ”๋“œ ๋‹จ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์†Œ๊ฐœํ•ด๋ณด๊ฒ ๋‹ค.

getExternalFilesDir ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ์•ฑ์˜ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๋ช…๋ น์–ด๋กœ, ์˜ˆ๋ฅผ๋“ค์–ด

getExternalFilesDir(data) ์™€ ๊ฐ™์ด ํ˜ธ์ถœํ•˜๋ฉด ๋Œ€๋žต

storage/emulated/0/Android/data/com.exercise.testapp/files/data์™€ ๊ฐ™์€

๊ฒฝ๋กœ๋ฅผ ๋ฑ‰์–ด์ค€๋‹ค. ์ด ๋•Œ ํ•ด๋‹น ๊ฒฝ๋กœ์— ์–ด๋–ค ํŒŒ์ผ์„ ์˜ฌ๋ ค๋†“๊ณ  ์“ฐ๊ณ  ์‹ถ์–ด Device File Explorer๋กœ ํ•ด๋‹น ๊ฒฝ๋กœ๋ฅผ ์ ‘๊ทผํ•˜๋ ค๊ณ ํ•˜๋ฉด

์•„๋ž˜์™€ ๊ฐ™์€ ํ™”๋ฉด์„ ๋ณด๊ฒŒ ๋  ์ˆ˜๋„ ์žˆ๋‹ค.

storage/emulated ๊ฒฝ๋กœ์—์„œ Permission denied๊ฐ€ ๋œฌ๋‹ค.

storage/emulated/0 ๊ฒฝ๋กœ์— ์ ‘๊ทผํ•  ์ˆ˜๊ฐ€ ์—†๋‹ค.

์ด ๊ฒฝ์šฐ ๊ฐ™์€ ๋””๋ ‰ํ† ๋ฆฌ์ง€๋งŒ ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ ‘๊ทผํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ™์€ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

storage/self/primary๋กœ ์ ‘๊ทผ

storage-self-primary๋ฅผ ํ†ตํ•œ ์ ‘๊ทผ

์ด ๋•Œ ๋ณธ์ธ์˜ ์•ฑ ๊ฒฝ๋กœ๋กœ ์ ‘๊ทผํ•˜์—ฌ files ํ•˜๋ถ€์— ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋ฉด, getExternalFilesDir๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด

์•ฑ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ํŠน๋ณ„ํ•œ ๊ถŒํ•œ์˜ ์š”์ฒญ ํ•„์š” ์—†์ด ์ž์œ ๋กญ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€