As http://www.catb.org/esr/faqs/smart-questions.html suggests, rather
than make the reader read through your entire code and run it himself
to figure out what the error is, if you tell us the error message and
which line of code it comes from, you are much more likely to get a
helpful answer.

No promises though, since you admit the code below is only 'almost'
complete;)

Also helpful would be to show us what happens when you access the same
data from the same database using the sqlite3 command in adb shell.
Then we would know for sure that your database is sound.

On Sep 17, 1:47 am, Muhammad Irfan <iffe...@gmail.com> wrote:
> Hi,
>
> there is no solution for this?
>
> Regards
>
> On Fri, Sep 17, 2010 at 7:50 AM, iffeess <iffe...@gmail.com> wrote:
> > Hello Every body,
> > I am new in this group. I am in a problem from many days and try to
> > resolve it. But unfortunately its difficult for me.
> > I am fetching data from data base and dsiplaying in the spiner.
> > Database created and working well but when I bind it with spiner then
> > it show error and force to shutdown the application.
>
> > This is the almost complete code.
>
> > import android.os.Bundle;
> > import android.app.Activity;
> > import android.content.ContentValues;
> > import android.database.Cursor;
> > import android.database.sqlite.SQLiteDatabase;
> > import android.widget.TextView;
> > import android.widget.Spinner;
> > import android.widget.SimpleCursorAdapter;
> > import android.app.ListActivity;
> > import static com.servanetdatabase.Constants.Table_Name;
> > import static com.servanetdatabase.Constants.KEY_SensorID;
> > import static com.servanetdatabase.Constants.KEY_type;
> > import static com.servanetdatabase.Constants.KEY_ThresouldValue;
> > import static com.servanetdatabase.Constants.KEY_Address;
> > import static com.servanetdatabase.Constants.KEY_City;
> > import static com.servanetdatabase.Constants.KEY_State;
> > import static com.servanetdatabase.Constants.KEY_Latitude;
> > import static com.servanetdatabase.Constants.KEY_GPSNo;
> > import static com.servanetdatabase.Constants.KEY_SensorID;
> > import android.widget.SimpleCursorAdapter;
> > import android.widget.Spinner;
> > import android.widget.ArrayAdapter;
>
> > public class ServaNetDatabase extends Activity {
>
> >        private static String[] FROM = { KEY_SensorID, KEY_type,
> > KEY_ThresouldValue, };
> >        private static String ORDER_BY = KEY_SensorID + " DESC";
> >        public static String[] PROJECTION;
> > //      int[] to = new int[]{android.R.id.text1};
>
> >           private DBAdapter events;
>
> >           @Override
> >           public void onCreate(Bundle savedInstanceState) {
> >              super.onCreate(savedInstanceState);
> >              setContentView(R.layout.main);
> >              events = new DBAdapter(this);
> >              try {
> >                 addEvent("This is an event");
> >                 Cursor cursor = getEvents();
> >                 showEvents(cursor);
> >              } finally {
> >                 events.close();
> >              }
>
> >           }
>
> >           private void addEvent(String string) {
> >                      // Insert a new record into the Events data source.
> >                      // You would do something similar for delete and
> > update.
> >                      SQLiteDatabase db = events.getWritableDatabase();
> >                      ContentValues values = new ContentValues();
> >                     // values.put(KEY_SensorID, 1);
> >                      values.put(KEY_type, 500);
> >                      values.put(KEY_ThresouldValue, 500);
> >                      db.insertOrThrow(Table_Name, null, values);
> >                   }
> >           private Cursor getEvents() {
> >                      // Perform a managed query. The Activity will handle
> > closing
> >                      // and re-querying the cursor when needed.
> >                      SQLiteDatabase db = events.getReadableDatabase();
> >                      Cursor cursor = db.query(Table_Name, FROM, null, null,
> > null,
> >                            null, ORDER_BY);
> >                      startManagingCursor(cursor);
> >                      return cursor;
> >                   }
>
> >           private void showEvents(Cursor cursor) {
>
> >                      SimpleCursorAdapter adapter =
> >                        new SimpleCursorAdapter(this,
> > android.R.layout.simple_spinner_item, cursor, FROM, null );
>
> > adapter.setDropDownViewResource(
> > android.R.layout.simple_spinner_dropdown_item );
> >                      // get reference to our spinner
> >                      Spinner s = (Spinner) findViewById( R.id.dspiner );
> >                      s.setAdapter(adapter);
>
> >                   }
>
> >                }
>
> > Any body can help me to resolve this issue?
>
> > Regards,
>
>

-- 
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

Reply via email to