用RecordStore在真机上储存不了,模拟器可以。
ljn2 2005-12-16 10:02:07 想试着按下保存后将输入的文字存下来,按下取回能读回来,模拟器上可以工作。
但是试了两部手机,都没有用。
public boolean Save()
{
RecordStore rs = null;
try
{
rs = RecordStore.openRecordStore("mysave3", true);
String str = m_pMF.m_MainInput.getString();
if (rs.getNumRecords()<1)
{
rs.addRecord(str.getBytes(),0,str.getBytes().length);
}
else
{
rs.setRecord(1,str.getBytes(),0,str.getBytes().length);
}
}
catch (RecordStoreException ex){}
try
{
rs.closeRecordStore();
}
catch (RecordStoreException ex1) {}
return true;
}
取回部分
public boolean Load()
{
RecordStore rs = null;
try
{
rs = RecordStore.openRecordStore("mysave3", true);
byte buf[] = new byte[1024];
int nCount = rs.getRecord(1,buf,0);
StringBuffer sb = new StringBuffer();
for (int i=0; i<nCount; i++)
{
sb.append((char)buf[i]);
}
String str = sb.toString();
m_pMF.m_MainInput.setString(str);
}
catch (RecordStoreException ex){}
try
{
rs.closeRecordStore();
}
catch (RecordStoreException ex1) {}
return true;
}
是不是需要设置什么先