Android 3.1 SQLite Database don't create table and insert fields to Database Device Explore monitor?












0














I am trying to create SQLite database via android 3.1. But it doesn't work as code following below. Please kindly help thanks.



Main Activity.class



public class MainActivity extends AppCompatActivity { DatabaseHelper myDb; 

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb = new DatabaseHelper(this); // this is contact, this is new extension of DatabaseHelper

}
}


DatabaseHelper.class



public class DatabaseHelper extends SQLiteOpenHelper { 
public static final String DATABASE_NAME = "Iters.db";
public static final String TABLE_NAME = "iters_table"; //called onCreate method
public static final String COL_1 = "ID";
public static final String COL_2 = "NAME";
public static final String COL_3 = "SURNAME";
public static final String COL_4 = "MARKS";


public DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, 1);
SQLiteDatabase db = this.getWritableDatabase();
}

@Override

public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE TABLE_NAME (ID INTEGER PRIMARY KEY AUTOINCREMENT," +
"NAME TEXT," +
"SURNAME TEXT," +
"MARKS INTEGER)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);
onCreate(db);
}
}









share|improve this question
























  • did you pull out the database and check it ?
    – Faiz Mir
    Nov 12 '18 at 4:05










  • Do you mean android 3.1 or Android Studio 3.1 ?
    – Vivek Mishra
    Nov 12 '18 at 4:30






  • 2




    Did you saw that your table name is actually TABLE_NAME and not iters_table
    – Vivek Mishra
    Nov 12 '18 at 4:32
















0














I am trying to create SQLite database via android 3.1. But it doesn't work as code following below. Please kindly help thanks.



Main Activity.class



public class MainActivity extends AppCompatActivity { DatabaseHelper myDb; 

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb = new DatabaseHelper(this); // this is contact, this is new extension of DatabaseHelper

}
}


DatabaseHelper.class



public class DatabaseHelper extends SQLiteOpenHelper { 
public static final String DATABASE_NAME = "Iters.db";
public static final String TABLE_NAME = "iters_table"; //called onCreate method
public static final String COL_1 = "ID";
public static final String COL_2 = "NAME";
public static final String COL_3 = "SURNAME";
public static final String COL_4 = "MARKS";


public DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, 1);
SQLiteDatabase db = this.getWritableDatabase();
}

@Override

public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE TABLE_NAME (ID INTEGER PRIMARY KEY AUTOINCREMENT," +
"NAME TEXT," +
"SURNAME TEXT," +
"MARKS INTEGER)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);
onCreate(db);
}
}









share|improve this question
























  • did you pull out the database and check it ?
    – Faiz Mir
    Nov 12 '18 at 4:05










  • Do you mean android 3.1 or Android Studio 3.1 ?
    – Vivek Mishra
    Nov 12 '18 at 4:30






  • 2




    Did you saw that your table name is actually TABLE_NAME and not iters_table
    – Vivek Mishra
    Nov 12 '18 at 4:32














0












0








0







I am trying to create SQLite database via android 3.1. But it doesn't work as code following below. Please kindly help thanks.



Main Activity.class



public class MainActivity extends AppCompatActivity { DatabaseHelper myDb; 

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb = new DatabaseHelper(this); // this is contact, this is new extension of DatabaseHelper

}
}


DatabaseHelper.class



public class DatabaseHelper extends SQLiteOpenHelper { 
public static final String DATABASE_NAME = "Iters.db";
public static final String TABLE_NAME = "iters_table"; //called onCreate method
public static final String COL_1 = "ID";
public static final String COL_2 = "NAME";
public static final String COL_3 = "SURNAME";
public static final String COL_4 = "MARKS";


public DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, 1);
SQLiteDatabase db = this.getWritableDatabase();
}

@Override

public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE TABLE_NAME (ID INTEGER PRIMARY KEY AUTOINCREMENT," +
"NAME TEXT," +
"SURNAME TEXT," +
"MARKS INTEGER)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);
onCreate(db);
}
}









share|improve this question















I am trying to create SQLite database via android 3.1. But it doesn't work as code following below. Please kindly help thanks.



Main Activity.class



public class MainActivity extends AppCompatActivity { DatabaseHelper myDb; 

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDb = new DatabaseHelper(this); // this is contact, this is new extension of DatabaseHelper

}
}


DatabaseHelper.class



public class DatabaseHelper extends SQLiteOpenHelper { 
public static final String DATABASE_NAME = "Iters.db";
public static final String TABLE_NAME = "iters_table"; //called onCreate method
public static final String COL_1 = "ID";
public static final String COL_2 = "NAME";
public static final String COL_3 = "SURNAME";
public static final String COL_4 = "MARKS";


public DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, 1);
SQLiteDatabase db = this.getWritableDatabase();
}

@Override

public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE TABLE_NAME (ID INTEGER PRIMARY KEY AUTOINCREMENT," +
"NAME TEXT," +
"SURNAME TEXT," +
"MARKS INTEGER)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);
onCreate(db);
}
}






android database sqlite device






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 5:17









V-rund Puro-hit

3,94082043




3,94082043










asked Nov 12 '18 at 3:46









butthry

92




92












  • did you pull out the database and check it ?
    – Faiz Mir
    Nov 12 '18 at 4:05










  • Do you mean android 3.1 or Android Studio 3.1 ?
    – Vivek Mishra
    Nov 12 '18 at 4:30






  • 2




    Did you saw that your table name is actually TABLE_NAME and not iters_table
    – Vivek Mishra
    Nov 12 '18 at 4:32


















  • did you pull out the database and check it ?
    – Faiz Mir
    Nov 12 '18 at 4:05










  • Do you mean android 3.1 or Android Studio 3.1 ?
    – Vivek Mishra
    Nov 12 '18 at 4:30






  • 2




    Did you saw that your table name is actually TABLE_NAME and not iters_table
    – Vivek Mishra
    Nov 12 '18 at 4:32
















did you pull out the database and check it ?
– Faiz Mir
Nov 12 '18 at 4:05




did you pull out the database and check it ?
– Faiz Mir
Nov 12 '18 at 4:05












Do you mean android 3.1 or Android Studio 3.1 ?
– Vivek Mishra
Nov 12 '18 at 4:30




Do you mean android 3.1 or Android Studio 3.1 ?
– Vivek Mishra
Nov 12 '18 at 4:30




2




2




Did you saw that your table name is actually TABLE_NAME and not iters_table
– Vivek Mishra
Nov 12 '18 at 4:32




Did you saw that your table name is actually TABLE_NAME and not iters_table
– Vivek Mishra
Nov 12 '18 at 4:32












1 Answer
1






active

oldest

votes


















0














It would appear that your issue is probably that you are naming the table TABLE_NAME rather than iters_table.



You could correct this by using :-



db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY," +
"NAME TEXT," +
"SURNAME TEXT," +
"MARKS INTEGER)");




  • Note I've also removed the AUTOINCREMENT keyword as you very likely don't need it (the ID column will still be auto-generated 1, then 2 then 3 etc (probably)) as :-


    • a) It's perhaps most mis-used keyword, and

    • b) It's a bit costly in terms of performance

    • You may wish to have a read of SQLite Autoincrement, considering that the the first sentence is The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed. I believe that the overhead is a loss of performance to the tune of between 8% and 12% (as per What are the overheads of using AUTOINCREMENT for SQLite on Android?
      )









share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255709%2fandroid-3-1-sqlite-database-dont-create-table-and-insert-fields-to-database-dev%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It would appear that your issue is probably that you are naming the table TABLE_NAME rather than iters_table.



    You could correct this by using :-



    db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY," +
    "NAME TEXT," +
    "SURNAME TEXT," +
    "MARKS INTEGER)");




    • Note I've also removed the AUTOINCREMENT keyword as you very likely don't need it (the ID column will still be auto-generated 1, then 2 then 3 etc (probably)) as :-


      • a) It's perhaps most mis-used keyword, and

      • b) It's a bit costly in terms of performance

      • You may wish to have a read of SQLite Autoincrement, considering that the the first sentence is The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed. I believe that the overhead is a loss of performance to the tune of between 8% and 12% (as per What are the overheads of using AUTOINCREMENT for SQLite on Android?
        )









    share|improve this answer


























      0














      It would appear that your issue is probably that you are naming the table TABLE_NAME rather than iters_table.



      You could correct this by using :-



      db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY," +
      "NAME TEXT," +
      "SURNAME TEXT," +
      "MARKS INTEGER)");




      • Note I've also removed the AUTOINCREMENT keyword as you very likely don't need it (the ID column will still be auto-generated 1, then 2 then 3 etc (probably)) as :-


        • a) It's perhaps most mis-used keyword, and

        • b) It's a bit costly in terms of performance

        • You may wish to have a read of SQLite Autoincrement, considering that the the first sentence is The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed. I believe that the overhead is a loss of performance to the tune of between 8% and 12% (as per What are the overheads of using AUTOINCREMENT for SQLite on Android?
          )









      share|improve this answer
























        0












        0








        0






        It would appear that your issue is probably that you are naming the table TABLE_NAME rather than iters_table.



        You could correct this by using :-



        db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY," +
        "NAME TEXT," +
        "SURNAME TEXT," +
        "MARKS INTEGER)");




        • Note I've also removed the AUTOINCREMENT keyword as you very likely don't need it (the ID column will still be auto-generated 1, then 2 then 3 etc (probably)) as :-


          • a) It's perhaps most mis-used keyword, and

          • b) It's a bit costly in terms of performance

          • You may wish to have a read of SQLite Autoincrement, considering that the the first sentence is The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed. I believe that the overhead is a loss of performance to the tune of between 8% and 12% (as per What are the overheads of using AUTOINCREMENT for SQLite on Android?
            )









        share|improve this answer












        It would appear that your issue is probably that you are naming the table TABLE_NAME rather than iters_table.



        You could correct this by using :-



        db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY," +
        "NAME TEXT," +
        "SURNAME TEXT," +
        "MARKS INTEGER)");




        • Note I've also removed the AUTOINCREMENT keyword as you very likely don't need it (the ID column will still be auto-generated 1, then 2 then 3 etc (probably)) as :-


          • a) It's perhaps most mis-used keyword, and

          • b) It's a bit costly in terms of performance

          • You may wish to have a read of SQLite Autoincrement, considering that the the first sentence is The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed. I believe that the overhead is a loss of performance to the tune of between 8% and 12% (as per What are the overheads of using AUTOINCREMENT for SQLite on Android?
            )










        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 '18 at 5:52









        MikeT

        14.9k102441




        14.9k102441






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53255709%2fandroid-3-1-sqlite-database-dont-create-table-and-insert-fields-to-database-dev%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation