2
我無法將數據插入到數據庫中。即使db文件爲空,我也會遇到out of memory
異常。BlackBerry OS 5.0中的內存不足SQLite
以下是我的代碼,請看看它。在此先感謝您的任何建議。
public class ThreeptalkDAO {
private static ThreeptalkDAO service;
private static Database database;
public static ThreeptalkDAO getInstance() throws CustomException {
if (service == null) {
service = new ThreeptalkDAO();
URI uri;
try {
uri = URI
.create("file:///SDCard/threeptalk/db/threeptalkdao.db");
database = DatabaseFactory.openOrCreate(uri);
// createMessagesTable();
} catch (Exception e) {
System.out.println("exp is:" + e.getMessage());
Dialog.alert(e + e.getMessage());
throw new CustomException(e.getMessage());
} // here path is like
// 'file:///SDCard/Databases/mytestApp/testdatabase.db'
}
return service;
}
public void createMessagesTable() throws CustomException {
try {
Statement statement = database
.createStatement("CREATE TABLE IF NOT EXISTS messages(message_id INTEGER PRIMARY KEY,message,status,message_type_id,response,date_added,sender,office,sent_on,phoneno)");
statement.prepare();
statement.execute();
statement.close();
} catch (DatabaseException e) {
// TODO Auto-generated catch block
throw new CustomException(e.getMessage());
}
}
public void insertMessages(Vector messages) throws CustomException {
for (int i = 0; i < messages.size(); i++) {
Messages m = (Messages) messages.elementAt(i);
try {
Statement statement = database
.createStatement("INSERT INTO messages (message_id,message,status,message_type_id, response,date_added,sender,office,sent_on,phoneno) VALUES ("
+ m.getMessageID()
+ ",'"
+ m.getMessage()
+ "','"
+ "unread"
+ "','"
+ m.getMessageType()
+ "','"
+ "0"
+ "','"
+ m.getMdate()
+ "','"
+ m.getSender()
+ "','"
+ m.getOffice()
+ "','"
+ m.getSentOn()
+ "','"
+ WebserviceFactory.getInstance().getPhoneNo()
+ "')");
statement.prepare();
statement.execute();
statement.close();
} catch (DatabaseException e) {
// TODO Auto-generated catch block
throw new CustomException(e.getMessage());
}
}
}
哪裏是被從拋出的異常?我不認爲'outofmemory'意味着你的數據庫已滿,這可能意味着你的黑莓手機內存已滿。 –
您的模擬器宣稱擁有多少可用RAM和多少可用磁盤空間? –
好的。是模擬器內存問題嗎?我知道模擬器的內存。我正在使用jre 5.0和9550模擬器。但首先我也無法創建表格 – user1427659