E
eintagsfliege
Gast
Hallo!
Ich versuche immoment eine Liste mit Einträgen aus einer Datenbank darzustellen, jedoch bekomme ich folgende Fehler:
Kann mir jemand sagen, was ich falsch mache? Bin leider noch Anfänger :-(
Ich versuche immoment eine Liste mit Einträgen aus einer Datenbank darzustellen, jedoch bekomme ich folgende Fehler:
Mein Code ist:Uncaught handler: thread main exiting due to uncaught exception
Code:
package com.application.edaytips;
import android.app.ListActivity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.SimpleCursorAdapter;
public class categories extends ListActivity {
final static String MY_DB_NAME = "alltagstipps";
final static String MY_DB_TABLE_1 = "categories";
final static String MY_DB_TABLE_2 = "content";
@Override
public void onCreate(Bundle savedInstance) {
setContentView(R.layout.categories);
SQLiteDatabase myDB = null;
myDB = this.openOrCreateDatabase(MY_DB_NAME, MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT _id, title FROM " + MY_DB_TABLE_1, null);
startManagingCursor(c);
// the desired columns to be bound
String[] columns = new String[] { "_id", "title" };
// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.lv_categories_item_text, R.id.lv_categories_item_text2 };
// create the adapter using the cursor pointing to the desired data as well as the layout information
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.categories_list, c, columns, to);
// set this adapter as your ListActivity's adapter
this.setListAdapter(mAdapter);
}
}
Kann mir jemand sagen, was ich falsch mache? Bin leider noch Anfänger :-(