简体   繁体   English

Android 2.1以编程方式卸载SDCard

[英]Android 2.1 programmatically unmount SDCard

I have an application that writes important data to the SDCard and encrypts it using AES, which later will be used by a desktop application. 我有一个将重要数据写入SDCard并使用AES对其加密的应用程序,以后将由桌面应用程序使用。 I have noticed that if I do not unmount the SDCard from the Settings menu sometimes the files don't get written at all, or are corrupted. 我注意到,如果不从“设置”菜单中卸载SD卡,有时文件根本不会被写入或损坏。

Is there anyway in Android 2.1 that I can unmount the SDCard programmatically? 无论如何,在Android 2.1中,我可以通过编程方式卸载SDCard吗? Because I'm pretty sure that from time to time the users will forget to do this, and I'll be the one fixing the problems and I really don't want this. 因为我很确定用户会不时忘记这样做,所以我将成为解决问题的人,我真的不想要这样做。

If this is not possible,what Linux command should I use to unmount the SDCard? 如果这不可能,那么我应该使用什么Linux命令来卸载SDCard? Since the application will run on some tablets that have a rooted OS. 由于该应用程序将在某些具有根操作系统的平板电脑上运行。

You should unmount what's using the sdcard in the proper order, for example 您应该以正确的顺序卸载使用sdcard的内容,例如

umount /mnt/sdcard/.android_secure
umount /mnt/sdcard

or, probably synchronizing the buffers with the filesystem would be enough 或者,将缓冲区与文件系统同步可能就足够了

sync; sync

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM