image.png StorageManager 在Android系统中,常用的存储介质是Nand Flash;系统的二进制镜像、 Android的文件系统等通常都保存在Nand Flash 中。...从Android 2.3开始新增了一个OBB文件系统和StorageManager类用来管理外部存储上的数据安全。...android.os.storage.StorageManager类的实例化方法需要使用 getSystemService(Contxt.STORAGE_SERVICE)才可以。...系统提供了 StorageManager 类,它有一个方法叫getVolumeList(),这个方法的返回值是一个StorageVolume数组,StorageVolume类中封装了挂载路径,挂载状态,...storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE); try {
storageManager; private final boolean persist; public DuplicateIDCacheImpl(final SimpleString...storageManager, final boolean persist) { this.address = address...; cacheSize = size; ids = new ArrayList(size); this.storageManager = storageManager...= -1) { storageManager.commit(txID); } pos = ids.size(); if (pos == cacheSize...(); storageManager.storeDuplicateIDTransactional(tx.getID(), address, duplID, recordID);
storageManager; private final boolean persist; public DuplicateIDCacheImpl(final SimpleString...storageManager, final boolean persist) { this.address = address...; cacheSize = size; ids = new ArrayList(size); this.storageManager = storageManager...(duplID, recordID); } else { if (persist) { recordID = storageManager.generateID...(); storageManager.storeDuplicateIDTransactional(tx.getID(), address, duplID, recordID);
如下所示: public static boolean isSdcardExists(Context context) { StorageManager storageManager = StorageManager.from...(context.getApplicationContext()); List<VolumeInfo volumes = storageManager.getVolumes(); for (VolumeInfo...} } } return false; } public static int isudiskExists(Context context) { int num = 0; StorageManager...storageManager = StorageManager.from(context.getApplicationContext()); List<VolumeInfo volumes =...storageManager.getVolumes(); for (VolumeInfo volInfo : volumes) { DiskInfo diskInfo = volInfo.getDisk
this.toString()); } redistributor = (new ConsumerHolder(new Redistributor(this, storageManager...storageManager; private final PostOffice postOffice; private final Executor executor; ...storageManager, final PostOffice postOffice, final Executor...(); this.storageManager = storageManager; this.postOffice = postOffice; this.executor...delivered return HandleStatus.NO_MATCH; } final Transaction tx = new TransactionImpl(storageManager
protected StorageManager createStorageManager() { if (configuration.isPersistenceEnabled()) {...是JDBCJournalStorageManager或者JournalStorageManager;否则创建的StorageManager是NullStorageManager processRoute...); } else { storageManager.updateScheduledDeliveryTime(reference...是JDBCJournalStorageManager或者JournalStorageManager;否则创建的StorageManager是NullStorageManager;PostOfficeImpl...的processRoute方法会判断message.isDurable(),若为true且durableRefCount为1则会执行storageManager.storeMessage或者storageManager.storeMessageTransactional
storageManager = (StorageManager) context.getSystemService(STORAGE_SERVICE); StorageVolume[] storageVolumes...; try { Method getVolumeList = StorageManager.class.getDeclaredMethod("getVolumeList"); storageVolumes...= (StorageVolume[]) getVolumeList.invoke(storageManager); Method getVolumeState = StorageManager.class.getDeclaredMethod...path = (String) getPath.invoke(storageVolume); Log.i(TAG, "StoragePath--- " + path); //这里需要用StorageManager...反射调用getVolumeState方法,并传入path地址,而在源码里,StorageManager的getVolumeState的方法的实现,也是将path重新创建为StorageVolume类,然后再调用其
this.toString()); } redistributor = (new ConsumerHolder(new Redistributor(this, storageManager...storageManager; private final PostOffice postOffice; private final Executor executor; private...storageManager, final PostOffice postOffice, final Executor...(); this.storageManager = storageManager; this.postOffice = postOffice; this.executor...delivered return HandleStatus.NO_MATCH; } final Transaction tx = new TransactionImpl(storageManager
throwIfUserRequired(); return sCurrentUser.getExternalDirs()[0]; } 内置sd卡取的sCurrentUser.getExternalDirs()中的第一个值,通过查看StorageManager...公有的方法,发下StorageManager@getStorageVolumes也能获取到所有的StorageVolume,但是通过StorageVolume对象只能调用到一些简单的方法,发现StorageVolume...uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/ 2、通过反射获取外置SD卡或挂载U盘路径 private StorageManager...mStorageManager; mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE); /
= null && storageManager.addToPage(store, message, context.getTransaction(), entry.getValue())) {...} else { storageManager.storeMessage(message); }...); } else { storageManager.updateScheduledDeliveryTime(reference...;对于tx不为null的会创建AddOperation添加到tx中,对于tx为null的则通过storageManager.afterCompleteOperations注册IOCallback,其done...;对于tx不为null的会创建AddOperation添加到tx中,对于tx为null的则通过storageManager.afterCompleteOperations注册IOCallback,其done
reference.isPaged()) { storageManager.updateDeliveryCount(reference); } AddressSettings...reference.isPaged() && reference.isDurable() && isDurable()) { storageManager.updateScheduledDeliveryTime...else { // if no TX we create a new one to commit at the end tx = new TransactionImpl(storageManager...ref.isPaged()) { storageManager.updateDeliveryCount(ref); }...ServerConsumerImpl的handle方法会在非browseOnly的情况下会调用ref.incrementDeliveryCount()来增加deliveryCount;必要的时候会执行storageManager.updateDeliveryCount
Storage API指的就是StorageManager,它有三个非常重要的方法estimate,persist和persisted,我们看下他们的浏览器兼容性: ?...基本上,现代浏览器都支持StorageManager和它的三个方法。 下面我们分别来看一下他们的使用。 StorageManager是一个接口,用来管理存储的权限和评估可用的空间。...我们可以通过navigator.storage 或者WorkerNavigator.storage 来获取到StorageManager。...我们看一下StorageManger的定义: interface StorageManager { estimate(): Promise; persist
android.content.Context; import android.content.pm.PackageManager; import android.os.Process; import android.os.storage.StorageManager...android.app.usage.StorageStatsManager; public static long getCacheSizeByAndroidO(Context mContext, String mPackageName) { StorageManager...storageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); StorageStatsManager...Context.STORAGE_STATS_SERVICE); try { StorageStats storageStats = storageStatsManager.queryStatsForPackage(StorageManager.UUID_DEFAULT
reference.isPaged()) { storageManager.updateDeliveryCount(reference); } AddressSettings...reference.isPaged() && reference.isDurable() && isDurable()) { storageManager.updateScheduledDeliveryTime...else { // if no TX we create a new one to commit at the end tx = new TransactionImpl(storageManager...ref.isPaged()) { storageManager.updateDeliveryCount(ref); }...ServerConsumerImpl的handle方法会在非browseOnly的情况下会调用ref.incrementDeliveryCount()来增加deliveryCount;必要的时候会执行storageManager.updateDeliveryCount
data/data//cache/ storage/emulated/0/Android/data//cache/ 当设备存储空间不足时,缓存文件可以被回收,系统回收策略为: 阈值 StorageManager...sm = (StorageManager) getSystemService(Context.STORAGE_SERVICE); UUID uuid = sm.getUuidForPath(getCacheDir...target = File(context.filesDir,"my-download") val sm = getSystemService(Context.STORAGE_SERVICE) as StorageManager...); intent.putExtra(StorageManager.EXTRA_UUID,uuid); // 需要的空间 intent.putExtra(StorageManager.EXTRA_REQUESTED_BYTES...,downloadSize); context.tartActivityForResult(intent,REQUEST_CODE); } > StorageManager#allocateBytes
= null && storageManager.addToPage(store, message, context.getTransaction(), entry.getValue())) {...} else { storageManager.storeMessage(message); } ...); } else { storageManager.updateScheduledDeliveryTime(reference...;对于tx不为null的会创建AddOperation添加到tx中,对于tx为null的则通过storageManager.afterCompleteOperations注册IOCallback,其done...;对于tx不为null的会创建AddOperation添加到tx中,对于tx为null的则通过storageManager.afterCompleteOperations注册IOCallback,其done
public static String getStoragePath(Context mContext,String keyword) { String targetpath = ""; StorageManager...mStorageManager = (StorageManager) mContext .getSystemService(Context.STORAGE_SERVICE); Class<
android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.storage.StorageManager...Environment.MEDIA_SHARED)); } public String getStoragePath(Context mContext, boolean is_removale) { StorageManager...mStorageManager = (StorageManager) mContext.getSystemService(Context.STORAGE_SERVICE); Class<?
()) { storageFlags = StorageManager.FLAG_STORAGE_DE; } else {...storageFlags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE; }...reconcileAppsDataLI(StorageManager.UUID_PRIVATE_INTERNAL, UserHandle.USER_SYSTEM,...storage = mContext.getSystemService(StorageManager.class); storage.registerListener(mStorageListener...); reconcileApps(StorageManager.UUID_PRIVATE_INTERNAL); } 至此,PackageManagerService启动流程分析完毕
领取专属 10元无门槛券
手把手带您无忧上云