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

  • Home
  • SEARCH
  • 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 7644729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:45:39+00:00 2026-05-31T09:45:39+00:00

I am trying to fetch the values from the database but i am getting

  • 0

I am trying to fetch the values from the database but i am getting the Exception unable to instantiate the activity componentinfo what is the problem I have mentioned all the activity names in the manifest file but still it force close.

public class DataBaseCreator {
private static final String DATABASE_NAME = "SetMessage.db";
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_TABLE = "Set_message";
public static final String KEY_ROWID = "_id";
public static final String KEY_MESSAGE = "Message";
public static final String KEY_TITTLE = "Tittle";
public static final String KEY_DATEFROM = "Date_From";
public static final String KEY_STARTTIME= "Start_Time";
public static final String KEY_EXPIRYDATE="Expiry_Date";
public static final String KEY_EXPIRYTIME="Expiry_Time";
private Context context;
private SQLiteDatabase db;
 private OpenHelper mDbHelper;
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() {
     mDbHelper = new OpenHelper(context);
     db = mDbHelper.getWritableDatabase();

}

public void close() {
    mDbHelper.close();
  }

public Cursor fetchRecords(long id) throws SQLException {

    Cursor mCursor =

      db.query(true, DATABASE_TABLE, new String[] { KEY_ROWID,
              KEY_MESSAGE,  KEY_TITTLE,KEY_DATEFROM ,KEY_STARTTIME,KEY_EXPIRYDATE,KEY_EXPIRYTIME}, KEY_ROWID + "=" + id, null,
          null, null, null, null);
    if (mCursor != null) {
      mCursor.moveToFirst();
    }
    return mCursor;

  }

}

& my main activity where i am trying to fetch the vales is

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    baseCreator.open();
    Cursor c=baseCreator.fetchRecords(1);
    Toast.makeText(this, "Tittle: " + c.getString(1) + " Message: "+ c.getString(2)+ " Date_from: "+ c.getString(3)+ " Start_Time: "+ c.getString(4)+ " Expiry_Date: "+ c.getString(5)+ " Expiry_Time: "+ c.getString(6), Toast.LENGTH_LONG).show();
    baseCreator.close();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.setdetails);
  • 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-31T09:45:40+00:00Added an answer on May 31, 2026 at 9:45 am

    You may forget create DataBaseCreator in onCreate method before open.

    baseCreator =  new DataBaseCreator(this.getApplicationContext());
    

    Updated:

    Add column _id to your table:

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE Set_message ("+
                "_id INTEGER PRIMARY KEY AUTOINCREMENT,"+
                "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)");
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fetch some HTML from various blogs and have noticed that different
I'm trying to fetch the most popular tags from all videos in my database
I am trying to fetch records from Oracle 9i database whose value are 'FOO
I am trying to fetch data from my database and when I display it
I'm trying to make a site that loads values from a database and then
I am trying to fetch data from database using php and send it to
I am trying to insert some values into a database from a form submitted
am trying to fetch some data from a form, but i cant for some
I'm trying to fetch Wikipedia pages using LWP::Simple , but they're not coming back.
I'm trying to fetch some settings from my membership provider in my asp.net application

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.