Memory and third-party external storage disk management provided by android, androidmemory
/*** @ Author intbird@163.com * @ time 20140606 */package com. intbird. utils; import java. io. file; import com. yilake. store. fileHelper; import android. graphics. bitmap; import android. OS. environment; import android. util. lruCache; public class CacheManager {// Single Instance private static CacheManager cacheInstance; // memory cache size private final int MEMO_CACHE_SIZE = (int) (Runtime. getRuntime (). maxMemory ()/1024); // File Cache size private fi Nal int DISK_CACHE_SIZE = 1024*1024*100; // memory cache private LruCache <String, Bitmap> mMemoryCache; // File Cache private DiskLruCache mDiskLruCache; private String cacheUrl = ""; public CacheManager () {// memory cache mMemoryCache = new LruCache <String, Bitmap> (MEMO_CACHE_SIZE) {protected int sizeOf (String key, Bitmap bitmap) {return bitmap. getByteCount ()/1024 ;};}; // setBitmapFileCacheDir (FileHelper. DISK_CACHE_FILEDIR);}/*** get Singleton * @ return */public static CacheManager getInstance () {if (cacheInstance = null) {cacheInstance = new CacheManager ();} return cacheInstance ;} /*** set the cache directory; * @ param cacheDir */public void setBitmapFileCacheDir (String cacheDir) {File cacheFile = getDiskFileCache (cacheDir); cacheUrl = cacheFile. getAbsolutePath (); mDiskLruCache = DiskLruCache. openCache (cacheFile, DISK_CACHE_SIZE);}/*** return cache directory path * @ return */public String getBitmapFileCacheDir () {return cacheUrl;} // public void addBitmapToCache (String fileUrl, Bitmap bitmap) {region (fileUrl, bitmap); addBitmapToDisk (fileUrl, bitmap );} public Bitmap getBitmapFromCache (String key) {Bitmap bmp = null; bmp = getBitmapFromMemory (key); if (bmp = null) {bmp = getBitmapFromDisk (key);} return bmp ;} /*** Add the image to the memory cache * @ param key * @ param bitmap */private void addBitmapToM Emory (String key, Bitmap bitmap) {if (getBitmapFromMemory (key) = null) {mMemoryCache. put (key, bitmap) ;}}/*** get memory cache image * @ param key * @ return */private Bitmap getBitmapFromMemory (String key) {return mMemoryCache. get (key);}/*** Add the image to the File Cache * @ param key * @ param bitmap */private void addBitmapToDisk (String key, Bitmap bitmap) {if (mDiskLruCache! = Null & mDiskLruCache. get (key) = null) {mDiskLruCache. put (key, bitmap) ;}}/*** get the image from the File Cache * @ param key * @ return */private Bitmap getBitmapFromDisk (String key) {if (mDiskLruCache! = Null) {return mDiskLruCache. get (key);} return null;}/*** get cache directory * @ return */public static File getDiskFileCache (String cacheDir) {String cachePath = Environment. MEDIA_MOUNTED.equals (Environment. getExternalStorageState () |! Environment. isExternalStorageRemovable ()? Environment. getExternalStorageDirectory (). getPath (): Environment. getDataDirectory (). getPath (); File file = new File (cachePath + File. separator + cacheDir); if (! File. exists () file. mkdir (); return file ;}}
There are four problems with the internal storage of mobile phones, mobile phone RAM, body memory, and external SD card capacity:
Thank you for choosing Lenovo products.
1. RAM is the running memory, which is used to ensure that the data and processes of the current program can run in an orderly manner. Because RAM is divided into AP and BP, AP is divided into user space (userspace), that is, the interface display, and some BP is hidden. RAM conversion. We can see that the computation in the body is in 1024 hexadecimal notation. The calculation method is about 1000 MB, and the conversion is 256 MB after hexadecimal notation.
2. ROM is the memory space of the mobile phone body, which involves a capacity problem. It can be divided into nominal capacity, actual capacity and available capacity. The memory space (ROM) is 8 GB, which is the nominal capacity. However, the actual ROM capacity will be much smaller than the nominal capacity, and some small loss will be deducted (different algorithms and particles ). This is divided into several parts, which can be viewed in system settings-storage, which is mainly divided into internal storage space (used to store the system and system programs) and the built-in memory card (which can be used to store files stored on a USB flash drive), which is usually used on Android phones.
If you are interested, you can also check ask.lenovomobile.com /? Q-110862.html.
If the technical solution we provide is valid, you can use it as a valid answer for your reference. Thank you.
Lenovo Mobile Phone tablet... [Official Certification]
When my mobile phone is an i9008 Samsung software, I said that the external memory space is insufficient, but the built-in memory of the mobile phone is still large. What should I do?
Because the rom of this mobile phone is only 512 MB, and the actual usage is 406 MB, it may be that all the items you downloaded earlier are in the rom of the mobile phone, so there is no place for the rom, we recommend that you move music, movies, and photos to the SD card. Then, you can "move" all programs that can be installed on the SD card to solve the problem of "insufficient external storage space" on your mobile phone.