LOGCAT如上。
程序如下:
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
TextView sizeTextView=(TextView) rootView.findViewById(R.id.allsize);
sizeTextView.setText("SD卡总大小:"+getSDTotalSize());
return rootView;
}
/**
* 获得SD卡总大小
*
* @return
*/
private String getSDTotalSize() {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSizeLong();
long totalBlocks = stat.getBlockCountLong();
return Formatter.formatFileSize(this.getActivity(),blockSize*totalBlocks);
}
}
为何会提示没有getBlockSizeLong(); 函数?不明白!