Hello Friends, i want to display selected column from database in the form of list. But application is forcibly closed when I try to run this application. Please help to solve this bug. Here is my code, main Activity
package com.example.android; import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import android.content.ContentValues; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.provider.BaseColumns; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.EditText; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.widget.Toast; public class SQLiteDemo extends ListActivity { private static final int DIALOG_ID = 100; private SQLiteDatabase database; private SimpleCursorAdapter dataSource; private View entryView; private EditText firstNameEditor; private EditText lastNameEditor; DBHelper helper; Cursor cursor; String t,t1; Intent intent; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); helper = new DBHelper(this); fillData(); } private void fillData() { //Cursor c=helper.getAllEmployees(); Cursor c = helper.fetchAllNotes(); //startManagingCursor(c); String[] from = new String[] { DBHelper.colName}; int[] to = new int[] {R.id.first}; dataSource = new SimpleCursorAdapter(this, R.layout.row1, c, from,to); ListView view = getListView(); view.setHeaderDividersEnabled(true); view.addHeaderView(getLayoutInflater().inflate(R.layout.row1, null)); setListAdapter(dataSource); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); // Get the item that was clicked int p1=position-1; cursor = (Cursor)this.getListAdapter().getItem(p1); t = cursor.getString(cursor.getColumnIndex(DBHelper.colName)); t1 = cursor.getString(cursor.getColumnIndex(DBHelper.colDate)); intent=new Intent(this,Edit.class); intent.putExtra("first",t); intent.putExtra("last",t1); startActivity(intent); //showDialog(DIALOG_ID); Toast.makeText(this, "You selected: " + t +" "+t1, Toast.LENGTH_LONG).show(); } } this my Xml file <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:id="@+id/rowLayout" android:orientation="horizontal" android:layout_width="fill_parent"> <TextView android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:layout_height="wrap_content" android:id="@+id/first" android:text="First name" /> </RelativeLayout> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en