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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:15:11+00:00 2026-06-03T01:15:11+00:00

I am unsure what is going on with my simple program to learn how

  • 0

I am unsure what is going on with my simple program to learn how to use a SQLite database. I based my program off the one found on this site. I decided to remove the issue of using variables and just wrote everything into my Create table string. I’ve also tried to do it with the appropriate KEY_CONTENT, etc to no avail. Hopefully this is enough code for you to see what is wrong. Also, is there any code I could write (Log or Toast output) in that would help to figure out what’s wrong?

public class SQLiteAdapter  {

public static final String DB_NAME = "My_Database";
public static final String DB_TABLE = "My_Table";
public static final int DB_VERSION = 1;
public static final String KEY_CONTENT = "My_Content";


String SCRIPT_CREATE_DATABASE = "CREATE TABLE My_Table (_id INTEGER PRIMARY KEY AUTOINCREMENT, My_Content TEXT);";

private SQLiteHelper sqLiteHelper;
private SQLiteDatabase sqLiteDatabase;

private Context context;

public SQLiteAdapter(Context c){
    context = c;
}
public SQLiteAdapter openToRead() throws android.database.SQLException {
      sqLiteHelper = new SQLiteHelper(context, DB_NAME, null, DB_VERSION);
      sqLiteDatabase = sqLiteHelper.getReadableDatabase();
      return this; 
     }
public SQLiteAdapter openToWrite() throws android.database.SQLException {
      sqLiteHelper = new SQLiteHelper(context, DB_NAME, null, DB_VERSION);
      sqLiteDatabase = sqLiteHelper.getWritableDatabase();
      return this; 
     }

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

public long insert(String content){

      ContentValues contentValues = new ContentValues();
      contentValues.put("My_Content", content);
      return sqLiteDatabase.insert("My_Table", null, contentValues);
     }
public int deleteAll(){
      return sqLiteDatabase.delete(DB_TABLE, null, null);
     }

     public String queueAll(){
      String[] columns = new String[]{KEY_CONTENT};
      Cursor cursor = sqLiteDatabase.query(DB_TABLE, columns, 
        null, null, null, null, null);
      String result = "";

      int index_CONTENT = cursor.getColumnIndex(KEY_CONTENT);
      for(cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()){
       result = result + cursor.getString(index_CONTENT) + "\n";
      }

      return result;
     }

     public class SQLiteHelper extends SQLiteOpenHelper {

      public SQLiteHelper(Context context, String name,
        CursorFactory factory, int version) {
       super(context, name, factory, version);
      }

      @Override
      public void onCreate(SQLiteDatabase db) {

       db.execSQL(SCRIPT_CREATE_DATABASE);
      }

      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
       // TODO Auto-generated method stub

      }

     }

}

My main activity starts dealing with the SQLite DB like this:

mySQLiteAdapter = new SQLiteAdapter(this);
        mySQLiteAdapter.openToWrite();
        mySQLiteAdapter.insert("First try");

And here is the Logcat:

04-25 14:19:37.404: E/Database(217): Error inserting My_Content=First try
04-25 14:19:37.404: E/Database(217): android.database.sqlite.SQLiteException: no such table: My_Table: , while compiling: INSERT INTO My_Table(My_Content) VALUES(?);
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1027)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1413)
04-25 14:19:37.404: E/Database(217):    at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1286)
04-25 14:19:37.404: E/Database(217):    at com.willmer.trialsqlite.SQLiteAdapter.insert(SQLiteAdapter.java:53)
04-25 14:19:37.404: E/Database(217):    at com.willmer.trialsqlite.TrialSQLiteActivity.onCreate(TrialSQLiteActivity.java:25)
04-25 14:19:37.404: E/Database(217):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-25 14:19:37.404: E/Database(217):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-25 14:19:37.404: E/Database(217):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-25 14:19:37.404: E/Database(217):    at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-25 14:19:37.404: E/Database(217):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-25 14:19:37.404: E/Database(217):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-25 14:19:37.404: E/Database(217):    at android.os.Looper.loop(Looper.java:123)
04-25 14:19:37.404: E/Database(217):    at android.app.ActivityThread.main(ActivityThread.java:4363)
04-25 14:19:37.404: E/Database(217):    at java.lang.reflect.Method.invokeNative(Native Method)
04-25 14:19:37.404: E/Database(217):    at java.lang.reflect.Method.invoke(Method.java:521)
04-25 14:19:37.404: E/Database(217):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-25 14:19:37.404: E/Database(217):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-25 14:19:37.404: E/Database(217):    at dalvik.system.NativeStart.main(Native Method)
  • 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-03T01:15:13+00:00Added an answer on June 3, 2026 at 1:15 am

    Replace your Code with the Following code.
    Because Table itself is a Keyword.

    String SCRIPT_CREATE_DATABASE = "CREATE TABLE My_Table (_id INTEGER PRIMARY KEY AUTOINCREMENT, My_Content TEXT);";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this going to break? It compiles fine but based on readings, I'm unsure
I'm unsure how to do this. One way is: import urllib.request; urllib.request.urlretrieve('www.example.com/file.tar', 'file.tar') Another
After googling I haven't found the anwser to this question so I am going
I'm trying to take up node.js for a comet-based program. Essentially I'm going to
Unsure how to get this string to work correctly. Keeps making my page blank.
I am unsure why this code will not work. When I click a button
I am unsure why is this rsync command is not syncing? rsync -v -e
I'm unsure if this is classed as a child and parent div. <div class=container>
I am unsure about which monitoring framework to use. Currently I am looking at
I'm new to using TableAdapters and I am unsure of what is going on.

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.