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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:39:12+00:00 2026-05-24T18:39:12+00:00

I am making an application which involves facebook integration. I have to store the

  • 0

I am making an application which involves facebook integration.
I have to store the access token so that it doesnt needs to login again to see the application. But i am not able to store the access token .
The following is the error which i get

08-16 13:57:53.236: ERROR/Database(7964): Error inserting acces_token=177852938929775|8e4aec98e182f7034b497766.3-618306968|YAriJqaRTDz1aIgNHjom_tdBnnw
08-16 13:57:53.236: ERROR/Database(7964): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
08-16 13:57:53.236: ERROR/Database(7964):     at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
08-16 13:57:53.236: ERROR/Database(7964):     at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:55)
08-16 13:57:53.236: ERROR/Database(7964):     at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1623)
08-16 13:57:53.236: ERROR/Database(7964):     at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1484)
08-16 13:57:53.236: ERROR/Database(7964):     at org.db.dbHelper.insertRows(dbHelper.java:63)
08-16 13:57:53.236: ERROR/Database(7964):     at org.neighbourhood.neighbourhood.onFacebookConnectorWorking(neighbourhood.java:142)

Code :-

  dbHelper db = new dbHelper(neighbourhood.this);
        db.open();
        ContentValues cv = new ContentValues();
        cv.put("acces_token",   
                  facebookConnector.getFacebook().getAccessToken());
        db.insertRows(cv, "facebook");
        db.close();

Code to inset values in database :-

public class dbHelper {

private final String DATABASE_NAME = "neighbourhood.db";
private final String TAG = "dbHelper";

private static final String DATABASE_CREATE_TABLE_LOGIN = "create table login" +
        " (is_login text not null);";

private static final String DATABASE_CREATE_TABLE_FACEBOOK = "create table "
        + "facebook"
        + " (name text not null,"
        + "first_name text not null," +
        "last_name text not null," +
        "gender text not null," +
        "email text not null," +
        "id text not null," +
        "birthday text not null," +
        "acces_token text not null);";


private SQLiteDatabase myDatabase;
private myDbhelper helper;

public dbHelper(Context context) {
    helper = new myDbhelper(context, DATABASE_NAME, null, 1);
}

/**
 * This method is used to open the database in Writable mode
 * 
 * @return instance of the database
 */
public dbHelper open() {
    try {
        myDatabase = helper.getWritableDatabase();
    } catch (SQLException ex) {
        ex.printStackTrace();
        }
    return this;
}

/**
 * This method is used for closing the database
 */
public void close() {
    myDatabase.close();
}


public long insertRows(ContentValues values, String tableName) {
    long val = myDatabase.insert(tableName, null, values);
    return val;
}

public Cursor getAllValues(String tableName) {
    Cursor myResult;
    myResult = myDatabase.query(tableName, null, null, null, null, null,
            null, null);

    return myResult;
}


private static class myDbhelper extends SQLiteOpenHelper {
    public myDbhelper(Context context, String name, CursorFactory factory,
            int version) {
        super(context, name, factory, version);
    }

    /**
     * this method is called when the database is created first time
     */
    @Override
    public void onCreate(SQLiteDatabase _db) {
        _db.execSQL(DATABASE_CREATE_TABLE_LOGIN);
        _db.execSQL(DATABASE_CREATE_TABLE_FACEBOOK);

    }

    /**
     * this method is called when the database version is changed
     */
    @Override
    public void onUpgrade(SQLiteDatabase _db, int _oldVersion,
            int _newVersion) {
        /*
         * _db.execSQL("DROP TABLE IF EXISTS all_audio");
         * _db.execSQL("DROP TABLE IF EXISTS all_video");
         * _db.execSQL("DROP TABLE IF EXISTS all_playlist");
         */
        _db.execSQL("DROP TABLE IF EXISTS all_playlist_song");
        onCreate(_db);

    }
}

}

  • 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-24T18:39:15+00:00Added an answer on May 24, 2026 at 6:39 pm

    Your schema specifies that all fields of your facebook table should be NOT NULL, but you are only inserting the acces_token field which will force the remaining fields to be NULL.

    private static final String DATABASE_CREATE_TABLE_FACEBOOK = "create table "
        + "facebook"
        + " (name text not null,"
        + "first_name text not null," +
        "last_name text not null," +
        "gender text not null," +
        "email text not null," +
        "id text not null," +
        "birthday text not null," +
        "acces_token text not null);";
    

    This is why the exception says android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed – your NOT NULL constraints are being violated.

    You need to either separate acces_token into a separate table (for instance, a hypothetical “admin” table), relax your constraints on the other fields, or insert an entire row of data instead of just the acces_token.

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

Sidebar

Related Questions

I am making an application which is a user interface to access 2 types
I'm making a php web application which stores user specific information that is not
I am thinking of making an (initially) small Web Application, which would eventually have
I am making a Java desktop application which involves lot of data, state, etc.
Im making an application which uses few languages. I would like to have possibility
I am making an application which needs a dial pad to dial phone number
I am making an application in which i have to make connnect to linkedin
I am making an application in android which integrates twitter and facebook logins and
I am making a GWT application that involves users being able to upload files.
I have been making application in which i click on image and new window

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.