Android make my app files only play from inside the app

為{幸葍}努か 提交于 2019-12-24 11:07:40

问题


I created an app in which the client can record few conversations and store in external storage. The client must be able to transfer the files if needed. So I am storing the recorded files in external storage. But client don't want the files to be played from outside the app, (from sd card) or from music player. Is it possible? Please let me know. Is using internal storage is the only way to do it?


回答1:


well this is not a programming question, but ...

you have 2 options here, decide based on your requirements

1) if you want the records to be simply not appear in any player or multi media app, you have 2 options: A- let the storing folder name starts with . (ex, .myrecords) OR B- add a file inside the folder named .nomedia

but this will not PROTECT the records, as if someone mounts the sd-card records can be copied and played on any device/pc

2) if you want to secure the files, you will need to encrypt them as advised by Joey Chong so once the recording completed, the file got encrypted, and stored on external storage once the user enters the playback screen, and picks a file to play, the app will decrypt it first, in a new (temp file) then play it, and delete the temp file once user leaves the playback screen.

-- for exporting the records to PC or other devices, you can add a function (button maybe) to export selected records, that simply decrypts the selected files into a specific folder, say (/appfolder/exported/) then user can copy them or do whatever... and user have to DELETE the files at export folder once purpose of export is ended. (maybe a button too) Clear Exported

storing in internal is not good idea, specially audio/video as it might be large files, and some devices does not have really large internal storage.

this could be more a comment but its way too long




回答2:


Is internal storage that you mention mean private location inside your app? As far as I know even you put in internal storage, Media player still able to locate the file unless it is inside your app private location.

What you can do is encrypt the file and store in external storage. When you need to play back, decrypt the file to your app private location and playback.



来源:https://stackoverflow.com/questions/26647217/android-make-my-app-files-only-play-from-inside-the-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!