Android 2.1以编程方式卸载SDCard [英] Android 2.1 programmatically unmount SDCard

查看:74
本文介绍了Android 2.1以编程方式卸载SDCard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将重要数据写入SDCard并使用AES对其加密的应用程序,以后将由台式机应用程序使用.我注意到,如果不从设置"菜单中卸载SD卡,有时文件根本不会被写入或损坏.

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. 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.

无论如何,在Android 2.1中是否可以通过编程方式卸载SDCard?因为我非常确定用户会不时忘记这样做,所以我将成为解决问题的人,我真的不想要这样做.

Is there anyway in Android 2.1 that I can unmount the SDCard programmatically? 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.

如果这不可能,那么我应该使用什么Linux命令来卸载SDCard?由于该应用程序将在某些具有植根操作系统的平板电脑上运行.

If this is not possible,what Linux command should I use to unmount the SDCard? Since the application will run on some tablets that have a rooted OS.

推荐答案

您应该以正确的顺序卸载使用sdcard的内容,例如

You should unmount what's using the sdcard in the proper order, for example

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

或者,也许将缓冲区与文件系统同步就足够了

or, probably synchronizing the buffers with the filesystem would be enough

sync; sync

这篇关于Android 2.1以编程方式卸载SDCard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆