0
내 질문은 간단합니다. 어떻게 응용 프로그램의 첫 번째 시작을 인식 할 수 있습니까? RMS에 값을 저장하고 앱이 시작될 때 그것을 읽음으로써 무엇을 할 것인지를 결정함으로써 성취 될 수 있다고 생각합니다.J2ME 응용 프로그램의 첫 번째 시작 감지
그러나 더 간단한 해결책이 있습니까?
내 질문은 간단합니다. 어떻게 응용 프로그램의 첫 번째 시작을 인식 할 수 있습니까? RMS에 값을 저장하고 앱이 시작될 때 그것을 읽음으로써 무엇을 할 것인지를 결정함으로써 성취 될 수 있다고 생각합니다.J2ME 응용 프로그램의 첫 번째 시작 감지
그러나 더 간단한 해결책이 있습니까?
내가 아는 한 더 간단한 방법은 없지만 어쨌든 매우 쉽습니다.
public static boolean isFirstRun() {
RecordStore rs = null;
try {
rs = RecordStore.openRecordStore("myAwesomeRecordStore", false); //check
return false; //record store exists, so it's not our first run
} catch (Exception e) {
//RecordStoreNotFoundException, but we need to catch others anway
try {
rs = RecordStore.openRecordStore("myAwesomeRecordStore", true); //create
} catch (Exception e1) {}
}
finally {
if (rs != null) try {rs.closeRecordStore();} catch (Exception e) {}
}
return true; //so, record store did not exist and it was created (if no error occured (there shouldn't be any errors anyway))
}