List of usage examples for android.os StatFs StatFs
public StatFs(String path)
From source file:mx.klozz.xperience.tweaker.fragments.DiskInfo.java
public static long Totalbytes(File f) { StatFs stat = new StatFs(f.getPath()); //return (long) stat.getBlockSize() * (long) stat.getBlockCount(); Deprecated xD the same of the last :) return stat.getBlockSizeLong() * stat.getBlockCountLong(); }
From source file:com.doomy.padlock.InfoFragment.java
/** * Gets available internal memory size. *// w w w . j a va2s .co m * @return The size of internal storage available. */ public String getAvailableInternalMemorySize() { File mPath = Environment.getDataDirectory(); StatFs mStat = new StatFs(mPath.getPath()); long mBlockSize = mStat.getBlockSize(); long mAvailableBlocks = mStat.getAvailableBlocks(); return Formatter.formatFileSize(getActivity(), mAvailableBlocks * mBlockSize); }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the available external memory size */// w ww .java 2s .c o m public double getAvailableExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double availableBlocks = stat.getAvailableBlocks(); return formatSizeGB(availableBlocks * blockSize); } else { return ERROR; } }
From source file:com.doomy.padlock.InfoFragment.java
/** * Gets total internal memory size.//from w w w . j a va2s .c om * * @return The total size of internal storage. */ public String getTotalInternalMemorySize() { File mPath = Environment.getDataDirectory(); StatFs mStat = new StatFs(mPath.getPath()); long mBlockSize = mStat.getBlockSize(); long mTotalBlocks = mStat.getBlockCount(); return Formatter.formatFileSize(getActivity(), mTotalBlocks * mBlockSize); }
From source file:com.wso2.mobile.mdm.api.DeviceInfo.java
/** *Returns the total external memory size// w w w. ja va2 s . c om */ public double getTotalExternalMemorySize() { if (externalMemoryAvailable()) { File path = Environment.getExternalStorageDirectory(); StatFs stat = new StatFs(path.getPath()); double blockSize = stat.getBlockSize(); double totalBlocks = stat.getBlockCount(); return formatSizeGB(totalBlocks * blockSize); } else { return ERROR; } }
From source file:com.sqkj.engine.image.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check//w w w.j a v a 2 s . c o m * @return The space available in bytes */ public static long getUsableSpace(File path) { if (SdkUtils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.example.demo_highlights.slidingmenu.fragment.LeftFragment.java
public void getDataSize() { textView2.setText("?"); progressBar2.setProgress(0);/*from w ww. j a v a 2 s . co m*/ // File path = Environment.getDataDirectory(); //sdcard StatFs statfs = new StatFs(path.getPath()); //blockSIZE long blocSize = statfs.getBlockSize(); //BLOCK long totalBlocks = statfs.getBlockCount(); //Block long availaBlock = statfs.getAvailableBlocks(); String[] total = filesize(totalBlocks * blocSize); String[] availale = filesize(availaBlock * blocSize); // int maxValue = Integer.parseInt(availale[0].replaceAll(",", "")) * progressBar2.getMax() / Integer.parseInt(total[0].replaceAll(",", "")); progressBar2.setProgress(100 - maxValue); // String Text="?"+total[0].replaceAll(",", "")+total[1]+"\n" // +"?:"+availale[0].replaceAll(",", "")+availale[1]; String Text = ":" + (Integer.parseInt(total[0].replaceAll(",", "")) - Integer.parseInt(availale[0].replaceAll(",", ""))) + availale[1]/*availale[0].replaceAll(",", "")+availale[1]*/ + " / " + total[0].replaceAll(",", "") + total[1]; textView2.setText(Text); }
From source file:com.androchill.call411.MainActivity.java
private Phone getHardwareSpecs() { ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); PhoneBuilder pb = new PhoneBuilder(); pb.setModelNumber(Build.MODEL);//from ww w . j a v a 2 s . com pb.setManufacturer(Build.MANUFACTURER); Process p = null; String board_platform = "No data available"; try { p = new ProcessBuilder("/system/bin/getprop", "ro.chipname").redirectErrorStream(true).start(); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while ((line = br.readLine()) != null) { board_platform = line; } p.destroy(); } catch (IOException e) { e.printStackTrace(); board_platform = "No data available"; } pb.setProcessor(board_platform); ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(mInfo); pb.setRam((int) (mInfo.totalMem / 1048576L)); pb.setBatteryCapacity(getBatteryCapacity()); pb.setTalkTime(-1); pb.setDimensions("No data available"); WindowManager mWindowManager = getWindowManager(); Display mDisplay = mWindowManager.getDefaultDisplay(); Point mPoint = new Point(); mDisplay.getSize(mPoint); pb.setScreenResolution(mPoint.x + " x " + mPoint.y + " pixels"); DisplayMetrics mDisplayMetrics = new DisplayMetrics(); mDisplay.getMetrics(mDisplayMetrics); int mDensity = mDisplayMetrics.densityDpi; pb.setScreenSize( Math.sqrt(Math.pow(mPoint.x / (double) mDensity, 2) + Math.pow(mPoint.y / (double) mDensity, 2))); Camera camera = Camera.open(0); android.hardware.Camera.Parameters params = camera.getParameters(); List sizes = params.getSupportedPictureSizes(); Camera.Size result = null; ArrayList<Integer> arrayListForWidth = new ArrayList<Integer>(); ArrayList<Integer> arrayListForHeight = new ArrayList<Integer>(); for (int i = 0; i < sizes.size(); i++) { result = (Camera.Size) sizes.get(i); arrayListForWidth.add(result.width); arrayListForHeight.add(result.height); } if (arrayListForWidth.size() != 0 && arrayListForHeight.size() != 0) { pb.setCameraMegapixels( Collections.max(arrayListForHeight) * Collections.max(arrayListForWidth) / (double) 1000000); } else { pb.setCameraMegapixels(-1); } camera.release(); pb.setPrice(-1); pb.setWeight(-1); pb.setSystem("Android " + Build.VERSION.RELEASE); StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); StatFs statInternal = new StatFs(Environment.getRootDirectory().getAbsolutePath()); double storageSize = ((stat.getBlockSizeLong() * stat.getBlockCountLong()) + (statInternal.getBlockSizeLong() * statInternal.getBlockCountLong())) / 1073741824L; pb.setStorageOptions(storageSize + " GB"); TelephonyManager telephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)); String operatorName = telephonyManager.getNetworkOperatorName(); if (operatorName.length() == 0) operatorName = "No data available"; pb.setCarrier(operatorName); pb.setNetworkFrequencies("No data available"); pb.setImage(null); return pb.createPhone(); }
From source file:com.gelakinetic.mtgfam.helpers.lruCache.ImageCache.java
/** * Check how much usable space is available at a given path. * * @param path The path to check/*from www . ja v a2s . c om*/ * @return The space available in bytes */ @TargetApi(VERSION_CODES.GINGERBREAD) private static long getUsableSpace(File path) { if (Utils.hasGingerbread()) { return path.getUsableSpace(); } final StatFs stats = new StatFs(path.getPath()); return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks(); }
From source file:com.dycody.android.idealnote.utils.StorageHelper.java
/** * Returns a directory size in bytes/*w ww. j a v a2 s . co m*/ */ @SuppressWarnings("deprecation") public static long getSize(File directory) { StatFs statFs = new StatFs(directory.getAbsolutePath()); long blockSize = 0; try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = statFs.getBlockSizeLong(); } else { blockSize = statFs.getBlockSize(); } // Can't understand why on some devices this fails } catch (NoSuchMethodError e) { Log.e(Constants.TAG, "Mysterious error", e); } return getSize(directory, blockSize); }