代号One Storage和FileSystem存储空间,可用空间,文件列表和清除空间 [英] Codename One Storage and FileSystemStorage space occupied, available space, list of files and clearing

查看:84
本文介绍了代号One Storage和FileSystem存储空间,可用空间,文件列表和清除空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个Codename One应用程序中,我需要一个区域(供开发人员和测试人员使用)显示:

Inside a Codename One app, I need an area (for developers and testers) that shows:


  • 该空间占用了多少空间存储空间+ FileSystemStorage;

  • 可用空间(如果没有足够的空间来记录视频或拍照,还可以提醒用户);

  • 存储+ FileSystemStorage内部已保存文件的列表;

  • 重置应用程序的选项,同时清除存储和FileSystemStorage。

  • how much space is occupied by the Storage + FileSystemStorage;
  • the available space (useful also to alert the user if there isn't enough space to record videos or to take photos);
  • the list of saved files inside Storage + FileSystemStorage;
  • an option to reset the app, clearing both Storage and FileSystemStorage.

在Codename One API中,我找到了 Storage.getInstance()。clearCache Storage.getInstance() .clearStorage(),但我找不到与FileSystemStorage等效的文件。

In the Codename One API, I found Storage.getInstance().clearCache and Storage.getInstance().clearStorage(), but I didn't find their equivalent for FileSystemStorage.

我想要一些有关所有这些要求的提示。谢谢。

I'd like some tips for all these requirements. Thanks.

推荐答案

存储空间受到管理,因此可以缓存其访问权限。文件系统清除将等同于格式化硬盘驱动器...不是一个API会期望的。

Storage is managed and so it's access is cached. File System clearing would be the equivalent of formatting your hard drive... Not an API one would expect to have.

由于存储空间平坦,因此透明存储的实现很漂亮琐碎的:

Since storage is flat the implementation of clear storage is pretty trivial:

    String[] l = listStorageEntries();
    int llen = l.length;
    for(int iter = 0 ; iter < llen ; iter++) {
        deleteStorageFile(l[iter]);
    }

FileSystemStorage 使用层次结构所以这不切实际。

FileSystemStorage uses hierarchies so this wouldn't be practical.

仅可通过 getRootAvailableSpace()在$code> FileSystemStorage 上获得可用空间。请注意,此API可能有点不稳定,因为操作系统并不总是以明确的方式报告存储。移动操作系统的分区方式有很多细微差别,通常 Storage 会根据其占用的空间映射到第一个根,但是我们不能保证这会

Available space is only available on FileSystemStorage via getRootAvailableSpace(). Notice that this API might be a bit flaky as the OS's don't always report storage in clear terms. There are a lot of nuances in the way mobile OS's are partitioned, usually Storage maps to the first root in terms of the space it takes up but we can't guarantee this will always be the case.

如果目标只是测试Android和iOS,则可以提供一种工具来检查应用在各自应用设置内的总存储量。

If the goal is simply testing both Android and iOS provide a tool to inspect the amount of total storage taken by the app within their respective app settings.

这篇关于代号One Storage和FileSystem存储空间,可用空间,文件列表和清除空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆