List of usage examples for android.os StatFs getBlockSize
@Deprecated public int getBlockSize()
From source file:com.esminis.server.mariadb.server.MariaDbServerLauncher.java
private long getFreeSpace(File file) { StatFs stat = new StatFs(file.getPath()); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); }/*from w w w . j a va 2 s.c o m*/ return (long) stat.getAvailableBlocks() * (long) stat.getBlockSize(); }
From source file:com.open.file.manager.CutCopyService.java
/** * Checks weither there's enough space to perform the operation * @param current//from w w w .ja va2s. co m * @return */ private boolean notEnoughSpace(FileCopyNode current) { StatFs targetfs = new StatFs(current.dstFile.getParent()); return current.size > (long) targetfs.getAvailableBlocks() * (long) targetfs.getBlockSize(); }
From source file:com.sogrey.sinaweibo.utils.FileUtil.java
/** * sdcard.//ww w.jav a2 s .co m * * @return the int */ @SuppressWarnings("deprecation") public static int freeSpaceOnSD() { StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); double sdFreeMB = ((double) stat.getAvailableBlocks() * (double) stat.getBlockSize()) / 1024 * 1024; return (int) sdFreeMB; }
From source file:com.error.hunter.ListenService.java
private void generateBugReport(ActivityManager.ProcessErrorStateInfo entry) { String condition;//from ww w . j a v a 2 s .c o m badProcess = entry.processName; String build = Build.DISPLAY; String fingerprint = Build.FINGERPRINT; String serial = Build.SERIAL; String product = Build.PRODUCT; String model = Build.MODEL; File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); @SuppressWarnings("deprecation") long blockSize = stat.getBlockSize(); @SuppressWarnings("deprecation") long availableBlocks = stat.getAvailableBlocks(); String memory = Formatter.formatFileSize(this, availableBlocks * blockSize).toString(); MemoryInfo mi = new MemoryInfo(); ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); long availableMegs = mi.availMem / 1048576L; strBuf.append("Problem detected in: ").append(badProcess); if (entry.tag != null) { strBuf.append(" (").append(entry.tag).append(")"); } strBuf.append("\nDevice product: " + product); strBuf.append("\nDevice model: " + model); strBuf.append("\nDevice build: " + build); strBuf.append("\nDevice fingerprint: " + fingerprint); strBuf.append("\nDevice SN: " + serial); strBuf.append("\nDevice available RAM (MB): " + availableMegs); strBuf.append("\nDevice free phisical memory: " + memory + "\n"); strBuf.append(getNetworkInfo()); strBuf.append("\n"); ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> procInfos = actvityManager.getRunningServices(1000); Iterator<RunningServiceInfo> taskIter = procInfos.iterator(); RunningServiceInfo info; while (taskIter.hasNext()) { info = taskIter.next(); if (info.process.equals(badProcess)) { strBuf.append("\nService " + info.service + " crash count: " + info.crashCount + " active since: " + info.activeSince + " process: " + info.process); } } strBuf.append("\n"); //android.os.Debug.MemoryInfo[] miPid = activityManager.getProcessMemoryInfo(new int[]{entry.pid}); //String memoryProc = miPid[0].toString(); //strBuf.append("\nRAM used by process (Process: " + entry.processName + " PID: " + entry.pid +"): " + memoryProc + "MB\n"); switch (entry.condition) { case ActivityManager.ProcessErrorStateInfo.CRASHED: condition = "CRASHED"; getDeviceProcessInfo(badProcess, entry.stackTrace); writeLogsToFile(condition, badProcess); break; case ActivityManager.ProcessErrorStateInfo.NOT_RESPONDING: condition = "ANR"; getDeviceProcessInfo(badProcess, ""); writeLogsToFile(condition, badProcess); break; default: condition = "<unknown>"; getDeviceProcessInfo(badProcess, entry.stackTrace); writeLogsToFile(condition, badProcess); break; } }
From source file:com.example.demo_highlights.slidingmenu.fragment.LeftFragment.java
public void getDataSize() { textView2.setText("?"); progressBar2.setProgress(0);//from w w w . ja v a2 s.c o 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.example.demo_highlights.slidingmenu.fragment.LeftFragment.java
public void getSDSize() { textView1.setText(""); progressBar1.setProgress(0);/* w w w.jav a 2 s .c o m*/ // if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File path = Environment.getExternalStorageDirectory(); //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(",", "")) * progressBar1.getMax() / Integer.parseInt(total[0].replaceAll(",", "")); progressBar1.setProgress(100 - maxValue); String Text = "SD:" + (Integer.parseInt(total[0].replaceAll(",", "")) - Integer.parseInt(availale[0].replaceAll(",", ""))) + availale[1]/*availale[0].replaceAll(",", "")+availale[1]*/ + " / " + total[0].replaceAll(",", "") + total[1]; textView1.setText(Text); } else if (Environment.getExternalStorageState().equals(Environment.MEDIA_REMOVED)) { // Toast.makeText(getActivity(), "sdCard", 1000).show(); textView1.setText("SD??"); } }
From source file:fr.sedona.volley.manager.HttpImageLoader.java
@SuppressLint("NewApi") private long getDiskCacheSpace(Context context) { String cachePath = context.getCacheDir().getPath(); File diskCacheDir = new File(cachePath); if (Build.VERSION.SDK_INT >= 9) { return Math.min(diskCacheDir.getFreeSpace() - (1024 * 1024 * 30), (long) 1024 * 1024 * 20); }//www .j ava 2 s. c om StatFs statFs = new StatFs(diskCacheDir.getAbsolutePath()); return (long) Math.min(statFs.getAvailableBlocks() * (long) statFs.getBlockSize() - (1024 * 1024 * 30), (long) 1024 * 1024 * 20); }
From source file:org.ormma.controller.OrmmaAssetController.java
/** * Cache remaining.//from w w w . j a v a2s .c o m * * @return the cache remaining */ public int cacheRemaining() { File filesDir = mContext.getFilesDir(); StatFs stats = new StatFs(filesDir.getPath()); int free = stats.getFreeBlocks() * stats.getBlockSize(); return free; }
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getExternalTotal() { long size;// www . j ava 2s . c om StatFs extStorageStatFs; String extStoragePath = getExternalStoragePath(); if (extStoragePath == null || !(new File(extStoragePath).exists())) { return getString(R.string.sto_sub_item_ext_storage_not_available); } extStorageStatFs = new StatFs(new File(extStoragePath).getAbsolutePath()); if (mIsApiAtLeast18) { size = extStorageStatFs.getTotalBytes(); } else { size = (long) extStorageStatFs.getBlockCount() * (long) extStorageStatFs.getBlockSize(); } return Utils.getFormattedSize(size); }
From source file:com.fallahpoor.infocenter.fragments.StorageFragment.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private String getExternalFree() { long size;//from w w w . jav a 2 s . c o m StatFs extStorageStatFs; String extStoragePath = getExternalStoragePath(); if (extStoragePath == null || !(new File(extStoragePath).exists())) { return getString(R.string.sto_sub_item_ext_storage_not_available); } extStorageStatFs = new StatFs(new File(extStoragePath).getAbsolutePath()); if (mIsApiAtLeast18) { size = extStorageStatFs.getAvailableBytes(); } else { size = (long) extStorageStatFs.getAvailableBlocks() * (long) extStorageStatFs.getBlockSize(); } return Utils.getFormattedSize(size); }