Hallo mal wieder ,
ich verwende in meiner App eine ExpandableList die Daten durch den SimpleCursorTreeAdapter bekommt.
Sobald ich in der Liste eine Gruppe schließe und eine andere öffne bekomm ich im LogCat folgende Warnung:
Code Zeile 104:
Ich hoffe mir kann jmd weiterhelfen...
Viele Grüße.
ich verwende in meiner App eine ExpandableList die Daten durch den SimpleCursorTreeAdapter bekommt.
Sobald ich in der Liste eine Gruppe schließe und eine andere öffne bekomm ich im LogCat folgende Warnung:
Code:
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: SELECT v._id AS _id, z.name AS nameZimmer, v.name AS nameVerbraucher, d.power AS power, CASE WHEN d.
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:100)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at de.smarthome.gui.HaushaltssteuerungActivity$3.getChildrenCursor(HaushaltssteuerungActivity.java:104)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.CursorTreeAdapter.getChildrenCursorHelper(CursorTreeAdapter.java:106)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.CursorTreeAdapter.getChildrenCount(CursorTreeAdapter.java:176)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.ExpandableListConnector.refreshExpGroupMetadataList(ExpandableListConnector.java:561)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.ExpandableListConnector.expandGroup(ExpandableListConnector.java:682)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.ExpandableListView.handleItemClick(ExpandableListView.java:567)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.ExpandableListView.performItemClick(ExpandableListView.java:527)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.os.Handler.handleCallback(Handler.java:587)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.os.Handler.dispatchMessage(Handler.java:92)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.os.Looper.loop(Looper.java:123)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at java.lang.reflect.Method.invokeNative(Native Method)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at java.lang.reflect.Method.invoke(Method.java:521)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-02 11:05:46.063: WARN/SQLiteCompiledSql(692): at dalvik.system.NativeStart.main(Native Method)
Code Zeile 104:
Code:
childCursor = dbConn.rawQuery(sql_child, new String[] { groupCursor.getString(groupCursor.getColumnIndex("nameZimmer")) });
Code:
...
private Cursor groupCursor;
private Cursor childCursor;
private NetzwerkService.NetzwerkServiceBinder mNetzwerkBinder;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.verbrauch_extended_list);
setTitle(getTitle() + " - Haushaltssteuerung");
registerForContextMenu(findViewById(android.R.id.list));
}
private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
if(msg.what == UPDATE_VIEW) {
mAdapter.notifyDataSetChanged(false);
}
super.handleMessage(msg);
}
};
@Override
public void onResume() {
super.onResume();
mListView = getExpandableListView();
String sql_gruppen = "SELECT v._id, zimmer_id AS _id, z.name AS nameZimmer, v.name AS nameVerbraucher, sum(d.power) AS power, v.image AS image " +
"FROM zimmer z " +
"JOIN verbraucher v ON z._id = v.zimmer_id " +
"LEFT OUTER JOIN details d ON v._id = d.verbraucher_id GROUP BY nameZimmer ORDER BY v.zimmer_id";
db = new SmartHomeDB(this);
dbConn = db.getReadableDatabase();
// DB-Abfrage um die Gruppen darzustellen
groupCursor = dbConn.rawQuery(sql_gruppen, null);
startManagingCursor(groupCursor);
// Adapter für ExpandableList erstellen
mAdapter = new SimpleCursorTreeAdapter(
this,
groupCursor,
R.layout.verbrauch_extended_list_group_row,
new String[] { "nameZimmer" , "power" },
new int[] { R.id.groupText1 , R.id.groupText2 },
R.layout.haushaltsgeraete_list_row,
new String[] { "image" , "nameVerbraucher" , "power" },
new int[] { R.id.deviceListImage , R.id.deviceListText1 , R.id.deviceListText2 }) {
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
String sql_child = "SELECT v._id AS _id, z.name AS nameZimmer, v.name AS nameVerbraucher, d.power AS power, " +
"CASE WHEN d.state = 'On' OR d.state = 'Running' THEN v.image_on ELSE v.image END AS image " +
"FROM zimmer z " +
"JOIN verbraucher v ON z._id = v.zimmer_id " +
"LEFT OUTER JOIN details d ON v._id = d.verbraucher_id WHERE z.name LIKE ?";
// DB-Abfrage um die Kindelemente darzustellen
childCursor = dbConn.rawQuery(sql_child, new String[] { groupCursor.getString(groupCursor.getColumnIndex("nameZimmer")) });
return childCursor;
}
};
// Der ExpandableListView den Adapter zuweisen
mListView.setAdapter(mAdapter);
}
Ich hoffe mir kann jmd weiterhelfen...
Viele Grüße.