Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:09:28+00:00 2026-05-31T03:09:28+00:00

I have written the Database class & trying to insert the values in the

  • 0

I have written the Database class & trying to insert the values in the database but i am getting Exception like this android.database.sqlite.SQLiteException: near “15”: syntax error: , while compiling:

insert into tbl_setmessage (Title,Message,DateFrom,StartTime,ExpiryDate,ExpiryTime)        values 
('Swapnil','hii','12-3-2012 '15:53'14-3-2012 '15:54')

what is the problem

My Databse class is

public class DataBaseCreator {
private static final String DATABASE_NAME = "SetMessage.db";
private static final int DATABASE_VERSION = 1;
private Context context;
private SQLiteDatabase db;
private SQLiteStatement insertStmt;

public DataBaseCreator(Context context) {
    this.context = context;
    OpenHelper openHelper = new OpenHelper(this.context);
    this.db = openHelper.getWritableDatabase();
}


public long insert(String TABLE_NAME, String TABLE_FIELDS, String TABLE_VALUES) {
    String INSERT = "insert into " 
            + TABLE_NAME + "("+ TABLE_FIELDS +") values ("+TABLE_VALUES+")";
    this.insertStmt = this.db.compileStatement(INSERT);
    return this.insertStmt.executeInsert();
}
public void closeDb() {
    this.db.close();
}  

private static class OpenHelper extends SQLiteOpenHelper {

    OpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE Set_message (Tittle VARCHAR(30) NOT NULL," +
     "Message VARCHAR(30) NOT NULL,"+
        "Date_from DATETIME NOT NULL,"+
         "Start_Time DATETIME NOT NULL,"+
        "Expiry_Date DATETIME NOT NULL,"+
         "Expiry_Time DATETIME NOT NULL)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP DATABASE IF EXISTS " + DATABASE_NAME);
        onCreate(db);
    }

}

public void open() {
    // TODO Auto-generated method stub

}

}

and main class is

btn_SetMessage.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            baseCreator.insert("tbl_setmessage ","Title,Message,DateFrom,StartTime,ExpiryDate,ExpiryTime","'"+tv1.getText()+"','"
                    +tv2.getText()+"','"+StartDate.getText()+"'"+StartTime.getText()+"'"+ExpiryDate.getText()+"'"+ExpiryTime.getText()+"'");
            Intent i=new Intent(SetMessage.this,SelectLocation.class);
            startActivity(i);
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:09:29+00:00Added an answer on May 31, 2026 at 3:09 am

    Try:

    btn_SetMessage.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
            baseCreator.insert("tbl_setmessage ","Title,Message,DateFrom,StartTime,ExpiryDate,ExpiryTime","'"+tv1.getText()+"','"
                    +tv2.getText()+"','"+StartDate.getText()+"','"+StartTime.getText()+"','"+ExpiryDate.getText()+"','"+ExpiryTime.getText()+"'");
            Intent i=new Intent(SetMessage.this,SelectLocation.class);
            startActivity(i);
        }
    });
    

    You lost some ” ‘,’ “

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a function to print database table to an array like this
I have written this stored procedure for one my operations in the database, but
I have written a database class but can't access the method from within: class
So I have this database class in PHP and I only have 1 function
I have a GUI class and a database class. I do something like: Dim
I have written a feed aggregator before but am trying to optimize it a
I have 50000 XML records like this in the database: <?xml version=1.0 encoding=UTF-8?> <root>
I want to create a database for my android application. I have written the
I have written a database application using a binary file as storage. it is
I have written an O/R database wrapper that generates some wrapper methods for stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.