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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:29:26+00:00 2026-06-10T14:29:26+00:00

i just started to develop an android application and i met with this error

  • 0

i just started to develop an android application and i met with this error and i dont know where did i do wrong. I want to insert the login details of my user so that i can grab the details when my user successfully logged in.

This is my logcat:

09-01 01:08:13.874: E/JSON(294): {"tag":"login","success":1,"error":0,"uid":"5040ef44839a09.93014710","user":{"name":"a","cname":"a","email":"a@gmail.com","created_at":"2012-09-01 01:07:16","updated_at":null}}
09-01 01:08:14.034: E/Database(294): Error inserting uid=5040ef44839a09.93014710 created_at=2012-    09-01 01:07:16 email=a@gmail.com cname=a name=a
09-01 01:08:14.034: E/Database(294): android.database.sqlite.SQLiteException: table login has no column named cname: , while compiling: INSERT INTO login(uid, created_at, email, cname, name) VALUES(?, ?, ?, ?, ?);
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
09-01 01:08:14.034: E/Database(294):    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
09-01 01:08:14.034: E/Database(294):    at com.stts.sparetimetradingsystem.library.DatabaseHandlerEmployer.addUser(DatabaseHandlerEmployer.java:83)
09-01 01:08:14.034: E/Database(294):    at com.stts.sparetimetradingsystem.employer.LoginEmployerActivity$LoginEmployer$1.run(LoginEmployerActivity.java:134)
09-01 01:08:14.034: E/Database(294):    at android.os.Handler.handleCallback(Handler.java:587)
09-01 01:08:14.034: E/Database(294):    at android.os.Handler.dispatchMessage(Handler.java:92)
09-01 01:08:14.034: E/Database(294):    at android.os.Looper.loop(Looper.java:123)
09-01 01:08:14.034: E/Database(294):    at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 01:08:14.034: E/Database(294):    at java.lang.reflect.Method.invokeNative(Native Method)
09-01 01:08:14.034: E/Database(294):    at java.lang.reflect.Method.invoke(Method.java:521)
09-01 01:08:14.034: E/Database(294):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 01:08:14.034: E/Database(294):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 01:08:14.034: E/Database(294):    at dalvik.system.NativeStart.main(Native Method)
09-01 01:08:15.174: E/AndroidRuntime(294): FATAL EXCEPTION: main
09-01 01:08:15.174: E/AndroidRuntime(294): java.lang.RuntimeException: Unable to destroy activity {com.stts.sparetimetradingsystem/com.stts.sparetimetradingsystem.employer.HomepageEmployerActivity}: java.lang.NullPointerException
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3655)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3673)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread.access$2900(ActivityThread.java:125)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.os.Looper.loop(Looper.java:123)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 01:08:15.174: E/AndroidRuntime(294):  at java.lang.reflect.Method.invokeNative(Native Method)
09-01 01:08:15.174: E/AndroidRuntime(294):  at java.lang.reflect.Method.invoke(Method.java:521)
09-01 01:08:15.174: E/AndroidRuntime(294):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 01:08:15.174: E/AndroidRuntime(294):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 01:08:15.174: E/AndroidRuntime(294):  at dalvik.system.NativeStart.main(Native Method)
09-01 01:08:15.174: E/AndroidRuntime(294): Caused by: java.lang.NullPointerException
09-01 01:08:15.174: E/AndroidRuntime(294):  at com.stts.sparetimetradingsystem.employer.HomepageEmployerActivity.onDestroy(HomepageEmployerActivity.java:340)
09-01 01:08:15.174: E/AndroidRuntime(294):  at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3642)
09-01 01:08:15.174: E/AndroidRuntime(294):  ... 11 more

This is my SQLiteDatabase code
package com.stts.sparetimetradingsystem.library;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHandlerEmployer extends SQLiteOpenHelper {

// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;

// Database Name
private static final String DATABASE_NAME = "stts";

// Login table name
private static final String TABLE_LOGIN = "login";

// Login Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_CNAME = "cname";
private static final String KEY_EMAIL = "email";
private static final String KEY_UID = "uid";
private static final String KEY_CREATED_AT = "created_at";

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

// Creating Tables
@Override
public void onCreate(SQLiteDatabase dbe) {
    // ORIGINAL 
    /*String CREATE_LOGIN_TABLE = "CREATE TABLE " + TABLE_LOGIN + "("
            + KEY_ID + " INTEGER PRIMARY KEY," 
            + KEY_NAME + " TEXT,"
            + KEY_CNAME + " TEXT,"
            + KEY_EMAIL + " TEXT UNIQUE,"
            + KEY_UID + " TEXT,"
            + KEY_CREATED_AT + " TEXT" + ")";

    dbe.execSQL(CREATE_LOGIN_TABLE);*/

    // TESTING HERE
    dbe.execSQL("CREATE TABLE " + TABLE_LOGIN + "(" 
            + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT," 
            + KEY_NAME + " TEXT NOT NULL,"
            + KEY_CNAME + " TEXT,"
            + KEY_EMAIL + " TEXT UNIQUE NOT NULL,"
            + KEY_UID + " TEXT NOT NULL,"
            + KEY_CREATED_AT + " TEXT NOT NULL);"
            );      
}

// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase dbe, int oldVersion, int newVersion) {
    // Drop older table if existed
    dbe.execSQL("DROP TABLE IF EXISTS " + TABLE_LOGIN);

    // Create tables again
    onCreate(dbe);
}

/**
 * Storing user details in database
 * */
//public void addUser(String name, String email, String uid, String created_at) {
public void addUser(String name, String cname, String email, String uid, String created_at) {
    SQLiteDatabase dbe = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(KEY_NAME, name); // Name
    values.put(KEY_CNAME, cname); // CName
    values.put(KEY_EMAIL, email); // Email
    values.put(KEY_UID, uid); // UID
    values.put(KEY_CREATED_AT, created_at); // Created At

    // Inserting Row
    dbe.insert(TABLE_LOGIN, null, values);
    dbe.close(); // Closing database connection
}

/**
 * Getting user data from database
 * */
/*public HashMap<String, String> getUserDetails(){
    HashMap<String,String> user = new HashMap<String,String>();
    String selectQuery = "SELECT  * FROM " + TABLE_LOGIN;

    SQLiteDatabase dbe = this.getReadableDatabase();
    Cursor cursor = dbe.rawQuery(selectQuery, null);
    // Move to first row
    cursor.moveToFirst();
    if(cursor.getCount() > 0){
        user.put("name", cursor.getString(1));
        user.put("cname", cursor.getString(2));
        user.put("email", cursor.getString(3));
        user.put("uid", cursor.getString(4));
        user.put("created_at", cursor.getString(5));
    }
    cursor.close();
    dbe.close();
    // return user
    return user;
}*/
public String getCName()
{
    String[] col = new String[] {KEY_NAME};
    SQLiteDatabase dbe = this.getReadableDatabase();
    Cursor c = dbe.query(TABLE_LOGIN, col, null, null, null, null, null);
    String res = "";
    int iCname = c.getColumnIndex(KEY_NAME);
    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
    {
        res = res + c.getString(iCname);
    }
    c.close();
    dbe.close();
    return res;
}

public String getEmail()
{
    String[] col = new String[] {KEY_EMAIL};
    SQLiteDatabase dbe = this.getReadableDatabase();
    Cursor c = dbe.query(TABLE_LOGIN, col, null, null, null, null, null);
    String res = "";
    int iEmail = c.getColumnIndex(KEY_EMAIL);
    for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
    {
        res = res + c.getString(iEmail);
    }
    c.close();
    dbe.close();
    return res;
}

/**
 * Getting user login status
 * return true if rows are there in table
 * */
public int getRowCount() {
    String countQuery = "SELECT  * FROM " + TABLE_LOGIN;
    SQLiteDatabase dbe = this.getReadableDatabase();
    Cursor cursor = dbe.rawQuery(countQuery, null);
    int rowCount = cursor.getCount();
    dbe.close();
    cursor.close();

    // return row count
    return rowCount;
}

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

I want to know where is the problem that cause the error. please help! thanks!

  • 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-10T14:29:28+00:00Added an answer on June 10, 2026 at 2:29 pm

    When you change your schema, as in adding the NOT NULL constraints or possibily adding the column KEY_CNAME, you need to inform your OpenHelper about these changes. It won’t find them automatically. The easiest way to do this is upgrading your database:

    private static final int DATABASE_VERSION = 2;
    

    You are trying to insert "5040ef44839a09.93014710" into a INTEGER PRIMARY KEY column. Normally SQLite only uses datatype affinity, but SQLite uses strict datatype matching for primary keys.

    This will throw an exception with the message: "Error: datatype mismatch"

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

Sidebar

Related Questions

I just started to develop my first android project. I want to add a
I have just started to develop android application yesterday and having a great fun
I have just started with android ... I have to develop an android application
I have just started Android application development, I have develop the application of Google
I've been programming for a while, but I just recently started to develop application
I just started to use Liferay and I want to develop a portlet using
As I'm just starting to develop an iPad application & have started getting used
I have just started to develop a brand new application and I have two
I have just started to develop a 2D Android game, something like squash a
I just started to develop an application that's meant to support an already existing

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.