I am new to android and I am getting follwing errors in my
compilation..
//Cannot make static reference to a non-static method
//Cannot make static reference to non-static fields
please help!

here's the code..

package database.create;


import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;


public class DBAdapter extends Activity {

                public static final String KEY_STDID = "_ID";
                public static final String KEY_FNAMEID = "FNAME";
                public static final String KEY_LNAMEID = "LNAME";
                public static final String KEY_DOBID = "DOB";
                public static final String KEY_HEIGHTID = "HEIGHT";
                public static final String KEY_WEIGHTID = "WEIGHT";
                private static final String TAG = "DBAdapter";

                private static final String DATABASE_NAME = "HEALTHCARE";
                private static final String DATABASE_TABLE = "PHYSICAL_FITNESS";
                private static final int DATABASE_VERSION = 1;

                public static final String DATABASE_CREATE = "create table
PHYSICAL_FITNESS (_id integer primary key,"
                        + "fname text not null, lname text not null," +
                        " d.o.b integer not null, height integer not null," + 
"weight
integer not null); ";

                private final Context context;
                private DatabaseHelper DBHelper;
                private SQLiteDatabase db;

                public DBAdapter(Context ctx) {
                        this.context = ctx;
                        DBHelper = new DatabaseHelper(context);
                                        }


                private static class DatabaseHelper extends SQLiteOpenHelper
                {
                        DatabaseHelper (Context context)
                        {
                                super(context, DATABASE_NAME, null, 
DATABASE_VERSION);
                        }

                        public void onCreate(SQLiteDatabase db)
                        {
                                db.execSQL(DATABASE_CREATE);
                        }
                        public void onUpgrade(SQLiteDatabase db, int oldVersion,
                    int newVersion)
                        {
                                Log.w(TAG, "Upgrading database from version " + 
oldVersion
                                                + " to "
                                                + newVersion + ", which will 
destroy all old data");
                                db.execSQL("DROP TABLE IF EXISTS 
physical_fitness");
                                onCreate(db);

                }

                        public DatabaseHelper open() throws SQLException
                        {
                                db = DBHelper.getWritableDatabase();
                                return this;
                        }

                        public void close()
                        {
                                DBHelper.close();
                        }
                        public long insertphysical_fitness (String _id, String 
FNAME,
String LNAME, String DOB, String HEIGHT, String WEIGHT)
                        {
                                ContentValues initialvalues = new 
ContentValues();
                                initialvalues.put(KEY_STDID,_id);
                                initialvalues.put(KEY_FNAMEID, FNAME);
                                initialvalues.put(KEY_LNAMEID, LNAME);
                                initialvalues.put(KEY_DOBID, DOB);
                                initialvalues.put(KEY_HEIGHTID, HEIGHT);
                                initialvalues.put(KEY_WEIGHTID, WEIGHT);
                                return db.insert(DATABASE_TABLE, null, 
initialvalues);

                        }

                        public boolean deleteTitle(long rowID){
                                return db.delete(DATABASE_TABLE, KEY_STDID + 
"=" + rowID, null) >
0;

                        }
                        public Cursor getAllTitles()
                    {

                                        return db.query(DATABASE_TABLE, new 
String[] {
                                        KEY_STDID,
                                        KEY_FNAMEID,
                                        KEY_LNAMEID,
                                KEY_DOBID,
                                KEY_HEIGHTID,
                                KEY_WEIGHTID},
                                null,
                                null,
                                null,
                                null,
                                null);
                    }

                    //---retrieves a particular title---
                    public Cursor getTitle(long _Id) throws SQLException
                    {
                        Cursor mCursor =
                                db.query(true, DATABASE_TABLE, new String[] {
                                                KEY_STDID,
                                                KEY_FNAMEID,
                                                KEY_LNAMEID,
                                                KEY_DOBID,
                                                KEY_HEIGHTID,
                                                KEY_WEIGHTID
                                                },
                                                KEY_STDID + "=" + _Id,
                                                null,
                                                null,
                                                null,
                                                null,
                                                null);
                        if (mCursor != null) {
                            mCursor.moveToFirst();
                        }
                        return mCursor;
                    }

                    //---updates a title---
                    public boolean updateTitle(long _Id, String FNAME,
                    String LNAME, String DOB, String HEIGHT, String WEIGHT)
                    {
                        ContentValues args = new ContentValues();
                        args.put(KEY_FNAMEID, FNAME);
                        args.put(KEY_LNAMEID, LNAME);
                        args.put(KEY_DOBID, DOB);
                        return db.update(DATABASE_TABLE, args,
                                         KEY_STDID + "=" + _Id, null) > 0;
                    }
                }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to