Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try to make a separate class for data base like </p> <pre><code>public class databasehandler extends SQLiteOpenHelper{ private static final int DATABASE_VERSION = 5; // Database Name private static final String DATABASE_NAME = "atabase"; // Contacts table name private static final String TABLE_Name = "task"; // Contacts Table Columns names private static final String event_name= "event_name"; private static final String start_date= "start_date"; private static final String KEYID="id"; private static final String end_date= "end_date"; private static final String event_pic= "event_pic"; private static final String event_desc= "event_desc"; private static final String wiki_url= "wiki_url"; private static final String event_cat= "event_cat"; public databasehandler(Context context){ super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub String CREATETABLE = "CREATE TABLE " + TABLE+ "(" + KEYID + " INTEGER PRIMARY KEY AUTOINCREMENT," + event_name+ " TEXT," + start_date+ " TEXT," + end_date+" TEXT "+ ..... so on ")"; db.execSQL(CREATE_TASK_TABLE); db.execSQL(CREATETABLE ); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // Drop older table if existed db.execSQL("DROP TABLE IF EXISTS " + TABLE); // Create tables again onCreate(db); } void adddata(Classname Object) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(event_name, Object.getevent_name()); values.put(start_date, Object.gestart_date()); values.put(TASK_ID, Object.getTASK_ID()); insert all values.... // Inserting Row db.insert(Table_tasknotification, null, values); // Closing database connection } } </code></pre> <p>and now Classname.java</p> <pre><code>public class Classname { //private variables name like String event_name; .... so on // Empty constructor public Classname (){ } // constructor public Classname (String event_name, String start_date,String end_date.....){ this.event_name= event_name; this.start_date=start_date; this.end_date=end_date; } public int getID(){ return this._id; } // setting id public void setID(int id){ this._id = id; } and all the get and set methods.... } </code></pre> <p>and in your main class:-</p> <pre><code>databasehandler handler=new databasehandler (context); handler.adddata(new Classname(event_name, start_date,end_date....)); </code></pre> <p>try this it will helo you :) and also check this link <a href="http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/" rel="nofollow">http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload