⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordstoreexample.java

📁 j2me实例代码
💻 JAVA
字号:
package rms;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.*;
import javax.microedition.lcdui.*;
import java.io.*;

public class RecordStoreExample extends MIDlet implements CommandListener{
	private Display display;
	private Alert alert;
	private Form form;
	private Command exit;
	private Command start;
	private RecordStore recordstore=null;
	public RecordStoreExample() {
		super();
		display=Display.getDisplay(this);
		exit=new Command("Exit",Command.SCREEN,1);
		start=new Command("Start",Command.SCREEN,1);
		form=new Form("Record Store");
		form.addCommand(exit);
		form.addCommand(start);
		form.setCommandListener(this);
	}
	protected void startApp() throws MIDletStateChangeException {
		display.setCurrent(form);
	}
	

	protected void pauseApp() {}

	protected void destroyApp(boolean arg0){}

	public void commandAction(Command c, Displayable d) {
		if(c==exit){
			destroyApp(false);
			notifyDestroyed();
		}
		else if(c==start){
			try{
				recordstore=RecordStore.openRecordStore("myRecordStore",true);
				
			}catch(Exception e){
				alert=new Alert("Creating fail",e.toString(),null,AlertType.WARNING);
				alert.setTimeout(Alert.FOREVER);
				display.setCurrent(alert);
			}
			try{
				recordstore.closeRecordStore();
			}catch(Exception e){
				alert=new Alert("Closing fail",e.toString(),null,AlertType.WARNING);
				alert.setTimeout(Alert.FOREVER);
				display.setCurrent(alert);
				
			}		
			if(RecordStore.listRecordStores()!=null){
				try{
					RecordStore.deleteRecordStore("myRecordStore");
				}catch(Exception e){
					alert=new Alert("Removing fail",e.toString(),null,AlertType.WARNING);
					alert.setTimeout(Alert.FOREVER);
					display.setCurrent(alert);
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -