【发布时间】:2010-12-16 07:18:55
【问题描述】:
我创建了一个应用程序,它将值存储到数据库中并检索存储的数据。在运行模式下运行应用程序时,一切似乎都工作正常(值已成功存储和检索),但当我在调试模式下运行时,进程抛出 IllegalStateException,到目前为止还没有找到原因。
获取对象Recording的方法如下:
public Recording getRecording(String filename) {
Recording recording = null;
String where = RECORDING_FILENAME + "='" + filename + "'";
Log.v(TAG, "retrieving recording: filename = " + filename);
try {
cursor = db.query(DATABASE_TABLE_RECORDINGS, new String[]{RECORDING_FILENAME, RECORDING_TITLE, RECORDING_TAGS, RECORDING_PRIVACY_LEVEL, RECORDING_LOCATION, RECORDING_GEO_TAGS, RECORDING_GEO_TAGGING_ENABLED, RECORDING_TIME_SECONDS, RECORDING_SELECTED_COMMUNITY}, where, null, null, null, null);
if (cursor.getCount() > 0) {
cursor.moveToFirst();
//String filename = c.getString(0);
String title = cursor.getString(1);
String tags = cursor.getString(2);
int privacyLevel = cursor.getInt(3);
String location = cursor.getString(4);
String geoTags = cursor.getString(5);
int iGeoTaggingEnabled = cursor.getInt(6);
String recordingTime = cursor.getString(7);
String communityID = cursor.getString(8);
cursor.close();
recording = new Recording(filename, title, tags, privacyLevel, location, geoTags, iGeoTaggingEnabled, recordingTime, communityID);
}
}
catch (SQLException e) {
String msg = e.getMessage();
Log.w(TAG, msg);
recording = null;
}
return recording;
}
它是从另一个类(设置)中调用的:
private Recording getRecording(String filename) {
dbAdapter = dbAdapter.open();
Recording recording = dbAdapter.getRecording(filename);
dbAdapter.close();
return recording;
}
运行上面的代码时一切正常,但随后我注意到另一个线程中出现异常: alt text http://img509.imageshack.us/img509/862/illegalstateexception.jpg
既不知道此异常的可能原因是什么,也不知道如何从该线程调试代码以诊断原因。
如果有人知道这里可能出现的问题,我将非常感激。
谢谢!
【问题讨论】:
-
异常的完整堆栈跟踪是什么?或者至少是相关位?
标签: database android exception