Samsung Galaxy S4 上的代号 One 存储行为
Codename One Storage behavior on Samsung Galaxy S4
在我的应用程序中,一些数据通过时间戳流式传输到设备中,因此我将其存储在哈希表结构中。如果用户需要,它也可以保存到存储器中以供以后查看或作为 CSV 文件通过电子邮件发送。这适用于 iOS 设备,以及两个不同(非三星)品牌的 Android 设备 运行 4.4 和 6.0。它不适用于 Samsung Galaxy S4 运行 5.0.1.
程序运行如下,用户按下停止按钮后,调用以下方法:
public void stopLogging() {
isLogging = false;
dataStorage.flushStorageCache();
dataStorage.writeObject(fileName, dataLogValues);
dataLogValues.clear();
}
dataLogValues 是哈希表。
当需要访问记录的数据时,会收集可用文件名的列表,其中包含用于访问特定日志的按钮。
public String[] getLogList() {
return dataStorage.listEntries();
}
之前在构造函数中初始化了 dataStorage
dataStorage = Storage.getInstance();
当从存储条目的 String[] 中选择日志时,将调用以下方法来检索文件:
public Hashtable<Long, Integer> getLog(String logName) {
dataStorage.clearCache();
Hashtable<Long, Integer> log = (Hashtable<Long, Integer>) dataStorage
.readObject(logName);
return log;
}
在 Samsung 设备上,我添加了一个对话框来显示每个日志文件名,因为我遍历了条目名称的 String[],我只得到以下内容:
"rList-(full package name).RallyPacControlStub" 其中 RallyPacControl 是应用程序的名称。如果我还显示 String[] 的大小,我将获得与我保存的日志数对应的预期条目数。这是我处理日志条目的代码,并避免了我不想要的文件。为此创建的日志文件仅由表示创建时间的 time/date 字符串命名。
String[] logList = dataBuffer.getLogList();
for (int i = 0; i < logList.length; i++) {
Dialog.show("Log name", logList[i], "OK", null);
if (!logList[i].equalsIgnoreCase("Cookies")
&& !logList[i].startsWith("CN1")
&& !logList[i].equals("Infopage")
&& !logList[i].startsWith("Chart")
&& !logList[i].startsWith("Log")) {
String log = logList[i];
Container buttonContainer = new Container();
buttonContainer.setUIID("LogButtonContainer");
buttonContainer.setName("LogListContainer");
buttonContainer.setLayout(new BoxLayout(BoxLayout.X_AXIS));
buttonContainer.add(new ShowLogButton(log, dataBuffer
.getLog(logList[i])));
buttonContainer.add(new ExportLogButton((logList[i])));
buttonContainer.add(new LogDeleteButton(log, this));
logsContainer.add(buttonContainer);
}
}
我一定是漏读了 Hashtable
的那一行。三星设备可能在层次结构中有一个隐藏文件来指示您可能可以访问的文件系统元数据,因此使用文件前缀通常是个好主意。
这也可能是 Log.p()
API 中写入该位置的文件。请注意,Storage
API 不保证只会返回您写入存储的文件。
在我的应用程序中,一些数据通过时间戳流式传输到设备中,因此我将其存储在哈希表结构中。如果用户需要,它也可以保存到存储器中以供以后查看或作为 CSV 文件通过电子邮件发送。这适用于 iOS 设备,以及两个不同(非三星)品牌的 Android 设备 运行 4.4 和 6.0。它不适用于 Samsung Galaxy S4 运行 5.0.1.
程序运行如下,用户按下停止按钮后,调用以下方法:
public void stopLogging() {
isLogging = false;
dataStorage.flushStorageCache();
dataStorage.writeObject(fileName, dataLogValues);
dataLogValues.clear();
}
dataLogValues 是哈希表。
当需要访问记录的数据时,会收集可用文件名的列表,其中包含用于访问特定日志的按钮。
public String[] getLogList() {
return dataStorage.listEntries();
}
之前在构造函数中初始化了 dataStorage
dataStorage = Storage.getInstance();
当从存储条目的 String[] 中选择日志时,将调用以下方法来检索文件:
public Hashtable<Long, Integer> getLog(String logName) {
dataStorage.clearCache();
Hashtable<Long, Integer> log = (Hashtable<Long, Integer>) dataStorage
.readObject(logName);
return log;
}
在 Samsung 设备上,我添加了一个对话框来显示每个日志文件名,因为我遍历了条目名称的 String[],我只得到以下内容:
"rList-(full package name).RallyPacControlStub" 其中 RallyPacControl 是应用程序的名称。如果我还显示 String[] 的大小,我将获得与我保存的日志数对应的预期条目数。这是我处理日志条目的代码,并避免了我不想要的文件。为此创建的日志文件仅由表示创建时间的 time/date 字符串命名。
String[] logList = dataBuffer.getLogList();
for (int i = 0; i < logList.length; i++) {
Dialog.show("Log name", logList[i], "OK", null);
if (!logList[i].equalsIgnoreCase("Cookies")
&& !logList[i].startsWith("CN1")
&& !logList[i].equals("Infopage")
&& !logList[i].startsWith("Chart")
&& !logList[i].startsWith("Log")) {
String log = logList[i];
Container buttonContainer = new Container();
buttonContainer.setUIID("LogButtonContainer");
buttonContainer.setName("LogListContainer");
buttonContainer.setLayout(new BoxLayout(BoxLayout.X_AXIS));
buttonContainer.add(new ShowLogButton(log, dataBuffer
.getLog(logList[i])));
buttonContainer.add(new ExportLogButton((logList[i])));
buttonContainer.add(new LogDeleteButton(log, this));
logsContainer.add(buttonContainer);
}
}
我一定是漏读了 Hashtable
的那一行。三星设备可能在层次结构中有一个隐藏文件来指示您可能可以访问的文件系统元数据,因此使用文件前缀通常是个好主意。
这也可能是 Log.p()
API 中写入该位置的文件。请注意,Storage
API 不保证只会返回您写入存储的文件。