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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:46:41+00:00 2026-06-03T04:46:41+00:00

As the topic imply i’ve a few problems creating a new table in sqlite.

  • 0

As the topic imply i’ve a few problems creating a new table in sqlite. what ever i do with my code i can’t create new table in the db. if i look at the db there’s just the android_metadata tb and nothing else. the code to create a new one is:

...
this.createTable(R.string.nametable, "_id INT PRIMARY KEY, " + "parentID INT, " + "name TEXT");
...

public void createTable(int id, String sql) {
        String table = this.getStringById(id);
        String _sql = "CREATE TABLE " + table + "(" + sql + ")";
        Log.d("Controller.createTable", _sql);
        this.mCurrentConnection.rawQuery(_sql, null);
        try {
            Cursor c = this.Select(id, "*", null);
            c.close(); 
            Log.d("Controller.createTable", "create finished");
        } catch (Exception e) {
            Log.d("Controller.createTable", "can't create table: " + table);
        }
    }

i open or create the db in the contructor of my app

if(this.mCurrentConnection == null || !this.mCurrentConnection.isOpen()) {
            this.mCurrentConnection = this.mContext.openOrCreateDatabase(this.mDB, Context.MODE_PRIVATE , null);
        }

I’ve tried everything: changing names of db / tb, reinstall app, placing “;” or not at the end of the command, tried it with a new clean vm.
i did not found any helpful existing post/answer that fix my prob.
if i execute the _sql statement

CREATE TABLE name_table(_id INT PRIMARY KEY, parentID INT, name TEXT)

in phpmyadmin (MySQL) everything works fine.

I’de be happy if you could help me.

regards Alex

EDIT: (answer for a comment below)

@VikramBodicherla: that’s the prob. the create statement itself did not cause any exeption. the select (check) statement does throw an

04-30 07:34:14.834: E/Database(305): Error inserting parentid=-1
name=blabla
04-30 07:34:14.834: E/Database(305): android.database.sqlite.SQLiteException:

no such table: name_table: , while compiling: INSERT INTO
name_table(parentid, name) VALUES(?, ?); 04-30 07:34:14.834:
E/Database(305): at
android.database.sqlite.SQLiteProgram.native_compile(Native Method)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:59)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:41)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1027)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1413)
04-30 07:34:14.834: E/Database(305): at
android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1286)
04-30 07:34:14.834: E/Database(305): at
unicorn.Heurazio.Controller.addName(Controller.java:156) 04-30
07:34:14.834: E/Database(305): at
unicorn.Heurazio.Controller.install(Controller.java:135) 04-30
07:34:14.834: E/Database(305): at
unicorn.Heurazio.StartUpActivity.onCreate(StartUpActivity.java:22)
04-30 07:34:14.834: E/Database(305): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-30 07:34:14.834: E/Database(305): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-30 07:34:14.834: E/Database(305): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-30 07:34:14.834: E/Database(305): at
android.app.ActivityThread.access$2200(ActivityThread.java:119) 04-30
07:34:14.834: E/Database(305): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-30 07:34:14.834: E/Database(305): at
android.os.Handler.dispatchMessage(Handler.java:99) 04-30
07:34:14.834: E/Database(305): at
android.os.Looper.loop(Looper.java:123) 04-30 07:34:14.834:
E/Database(305): at
android.app.ActivityThread.main(ActivityThread.java:4363) 04-30
07:34:14.834: E/Database(305): at
java.lang.reflect.Method.invokeNative(Native Method) 04-30
07:34:14.834: E/Database(305): at
java.lang.reflect.Method.invoke(Method.java:521) 04-30 07:34:14.834:
E/Database(305): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.runZygoteInit.java:860)
04-30 07:34:14.834: E/Database(305): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 04-30
07:34:14.834: E/Database(305): 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-03T04:46:43+00:00Added an answer on June 3, 2026 at 4:46 am

    You really really really want to use the SQLiteOpenHelper class and its associated pattern: it is not just for upgrades, it handles cleanly creating the table(s) as well.

    Also, your create statement should probably look like this:

    CREATE TABLE name_table (_id  INTEGER PRIMARY KEY AUTOINCREMENT, parentID INTEGER, name TEXT)
    

    EDIT: from your trace, your CREATE TABLE is never run (hence the table doesn’t exist). use the SQLiteOpenHelper and the execSQL function to create the table and you should be all set.

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

Sidebar

Related Questions

This topic can look similar to others but I haven't found any usable answer
I have read some topic regarding with my question but there code doesn't work
The topic has already been on the table in some previous questions. New elements
Topic is self explanatory. I found xaml code to do it for an Expander,
As topic suggested, how can I unit test a function that does not return
Summary: I can run unit tests and code-coverage, but the report only includes NUnit
as topic says, how do I get a td in a table by it's
As the topic states - is there any technology that would let me write
I know that this topic was discussed there a lot of times, but I've
Related Topic: How to write a:hover in inline CSS? I need to create an

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.