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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:13:57+00:00 2026-06-06T19:13:57+00:00

I am attempting to use a SQLite database to store emails locally in android.

  • 0

I am attempting to use a SQLite database to store emails locally in android. When I first call context.getWritableDatabase(), the database does not yet exist and is created. I am getting a syntax error on the create statement… My code looks like this…

private static final String DATABASE_NAME = "views.db";
    private static final int DATABASE_VERSION = 1;

    public static final String TABLE_VIEWS = "views";

    private static final String KEY_ID = "id";
    private static final String KEY_INDEX = "index";
    private static final String KEY_FROM = "from";
    private static final String KEY_UNREAD = "unread";
    private static final String KEY_SUBJECT = "subject";
    private static final String KEY_BODY = "body";


    // Database creation sql statement
    private static final String CREATE_VIEWS_TABLE = "CREATE TABLE " + TABLE_VIEWS + " ("
            + KEY_ID + " INTEGER PRIMARY KEY," 
            + KEY_INDEX + " INTEGER NOT NULL,"
            + KEY_UNREAD + " TEXT NOT NULL," 
            + KEY_SUBJECT + " TEXT NOT NULL,"
            + KEY_FROM + " TEXT NOT NULL," 
            + KEY_BODY + " TEXT NOT NULL);";

I am new to SQLite syntax and I have been searching for what could cause this with no avail. Any idea whats causing this? A database is really the best way to store such data locally.

The exact error reads as follows..

07-01 17:54:42.827: E/AndroidRuntime(3036): Caused by: android.database.sqlite.SQLiteException: near "index": syntax error: CREATE TABLE views (id INTEGER PRIMARY KEY,index INTEGER NOT NULL,unread TEXT NOT NULL,subject TEXT NOT NULL,from TEXT NOT NULL,body TEXT NOT NULL);
  • 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-06T19:13:59+00:00Added an answer on June 6, 2026 at 7:13 pm

    You cannot use the keyword ‘index’ as your table column name, change it to something else like tbl_index instead.

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

Sidebar

Related Questions

I am attempting to use the following code to search a database using words
I'm trying to use DbLinq with a SQLite database, but I'm running into a
I am attempting to insert data into a local SQLITE database file from a
I am attempting to use a parametrized LIKE query with Python's Sqlite library as
I'm attempting to use mysql after only having worked with sqlite in the past.
Attempting to use JRuby 1.2.0 and Rails 2.3.2 with an embedded Derby database. I've
I am attempting to use XMLParse against content that is not valid xhtml. In
I am attempting to use the haml-jekyll-extension only I do not understand how to
I'm writing my first database application. It's a C# WinForms application with a SQLite
I have a database winforms application using SQLite written in C#. I'm attempting to

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.