您的位置:首页 > 移动开发 > Android开发

android.os.SystemProperties和android.os.Environment

2017-03-14 20:50 836 查看
android.os.SystemProperties介绍

public class SystemProperties{
public static String get(String key){}
public static String get(String key,String def){}
public static int getInt(String key,int def){}
public static long getLong(String key,long def){}
public static boolean getBoolean(String key,boolean def){}
public static void set(String key,String val){}
}


android.os.Environment介绍
if(!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
Toast.makeText(context,”not found SDCard”,Toast.LENGTH_LONG).show();
}else{
try{
File file=new File(Evironment.getExternalStorageDirectory(),”/text.txt”);
FileOutputStream fos=new FileOutputStream(file);
fos.write(content.getBytes());
fos.flush();
fos.close();
}catch(Exception e){
e.printStackTrace();
}
}


其实Android Environment.getExternalStorageDirectory() 获取的 SD卡和手机本身带的存储 ;这两个存储都是外部储存,真正的内部储存位置是data/data/包名,所以用了这个会出现还是存到了手机自带存储上,而不是SD卡上

主要方法:

getRootDierctory()//获取根目录

getDataDirectory()//获取data目录

getExternalStorageDirectory()//获取sd卡目录

getDownloadCacheDirectory()//获取下载文件的缓存目录

getExternalStorageState()//sdcard的状态有:removed,unmounted,checking,nofs,mounted,mounted_ro,shared,unmountable,bad_removal
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: