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 8860737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:19:31+00:00 2026-06-14T15:19:31+00:00

im having a problem trying to establish a database in android, everytime i log

  • 0

im having a problem trying to establish a database in android, everytime i log in, the log cat says that no such table.

public class DatabaseOnline extends SQLiteOpenHelper {


private static final int DATABASE_VERSION = 1;


private static final String DATABASE_NAME = "name";

private static final String TABLE_LOGIN = "online";


private static final String KEY_ID = "Registration_id";
private static final String KEY_NAME = "Name";
private static final String KEY_PASSWORD = "Password";
private static final String KEY_UNIQUEID = "unique_id";

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


@Override
public void onCreate(SQLiteDatabase db) {
    String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
            + KEY_NAME + " VARCHAR (255), " + KEY_PASSWORD
            + " VARCHAR (255), " + KEY_ID + " VARCHAR(255), "
            + KEY_UNIQUEID + " VARCHAR (255)" + ")";
    db.execSQL(CREATE_LOGIN_TABLE);
}



public void addUser(String name, String password, String regId,
        String unique_id) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_NAME, name); // Name
    values.put(KEY_PASSWORD, password); // Email
    values.put(KEY_ID, regId);
    values.put(KEY_UNIQUEID, unique_id);
    // Inserting Row
    db.insert(TABLE_LOGIN, null, values);
    db.close(); // Closing database connection
}


public int getRowCount() {
    String countQuery = "SELECT  * FROM " + TABLE_LOGIN;
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(countQuery, null);
    int rowCount = cursor.getCount();
    db.close();
    cursor.close();

    // return row count
    return rowCount;
}

/**
 * Re crate database Delete all tables and create them again
 * */
public void resetTables() {
    SQLiteDatabase db = this.getWritableDatabase();
    // Delete All Rows
    db.delete(TABLE_LOGIN, null, null);
    db.close();
}

}

the problem is when i log in:

    DatabaseOnline db = new DatabaseOnline(getApplicationContext());
db.getWritableDatabase();
JSONObject json_user = json.getJSONObject("user");

System.out.println("unique id " + json_user.getString("unique_id"));
System.out.println("password " + json_user.getString("password"));
  db.addUser(json_user.getString("name"),json_user.getString("password"),json_user.getString("regId"),json_user.getString("unique_id"));                                                   

Intent dashboard = new Intent(getApplicationContext(),Main.class);
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
finish();                               

what appears is that android didnt create the database.
and here is the log cat:

11-20 21:42:15.162: E/SQLiteLog(1176): (1) no such table: online
11-20 21:42:15.282: E/SQLiteDatabase(1176): Error inserting unique_id=50a939dc9fa8a4.09780382 Name=v Registration_id=APA91bHnScWAF0xjtMjyHTvHx3ON6Eu_8on6kZUL5EvDmtAK8WDxwBVpNyMoapaTl0-ProAnY0m9VZbS-0OPeMshQkeU7ZOHlfI8tUAVJbeIgoe9sdL061ntJ8MnyglrLHK2BOWH2K1n Password=9e3669d19b675bd57058fd4664205d2a
11-20 21:42:15.282: E/SQLiteDatabase(1176): android.database.sqlite.SQLiteException: no such table: online (code 1): , while compiling: INSERT INTO online(unique_id,Name,Registration_id,Password) VALUES (?,?,?,?)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at guc.edu.i.DatabaseOnline.addUser(DatabaseOnline.java:66)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at guc.edu.i.Login.login(Login.java:199)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at guc.edu.i.Login$7.run(Login.java:146)
11-20 21:42:15.282: E/SQLiteDatabase(1176):     at java.lang.Thread.run(Thread.java:856)
  • 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-06-14T15:19:32+00:00Added an answer on June 14, 2026 at 3:19 pm

    Is this the first time the database is being created? try changing

    private static final int DATABASE_VERSION = 1;

    to

    private static final int DATABASE_VERSION = 2;

    That would cause the Table to be created and should sort out the issue

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

Sidebar

Related Questions

I'm having a problem trying to create a Javascript function that checks all the
I am having problem that when i am trying to submit the form by
I'm having a problem trying to print some data of a table. I'm new
I’m having a problem trying to detect if a table exists using jQuery. The
Having a problem trying to return field names from an MSSQL database via odbc
I am having a problem trying to scroll a table which has variable amount
I am having a problem trying to use the prependTo() function in jQuery... for
I'm having a problem trying to format the output on the jQuery UI datepicker.
I'm having a problem trying to make eclipse and aspectj work for Dynamic Web
I'm having a problem when trying to pass an array back to a COM

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.