有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

mobile是一个Java Microedition RMS,在打开时标记为已修改,但未进行数据更改?

我想知道打开RMS记录是否会检查它是否在javame中被修改。 比如说

RecordStore rs;

//First RMS access 
rs.open("gamescores",true);
rs.addRecord(null,0,0);
rs.closeRecordStore;

//Second RMS access
rs = RecordStore.open("gamescores",true);
long timeStamp = rs.getLastModified();
rs.closeRecordStore();

getLastModified()将返回第一次RMS访问或第二次RMS访问的时间


共 (2) 个答案

  1. # 1 楼答案

    另一种方法用于跟踪记录的修改-getVersion()

    Each time a record store is modified (by addRecord, setRecord, or deleteRecord methods) its version is incremented. This can be used by MIDlets to quickly tell if anything has been modified. The initial version number is implementation dependent. The increment is a positive integer greater than 0. The version number increases only when the RecordStore is updated. The increment value need not be constant and may vary with each update.

    至于getLastModified方法,其规范不允许以可移植的方式可靠地告诉您所询问的差异:

    Returns the last time the record store was modified, in the format used by System.currentTimeMillis().

  2. # 2 楼答案

    到目前为止,我从未使用过这个getLastModified()方法,所以我用谷歌搜索它,找到了和example。因此,是的,该方法以长格式返回上次修改的时间,您可以轻松地将其转换为日期