Note that there are some explanatory texts on larger screens.

plurals
  1. POcannot create multiple tables in a database
    text
    copied!<p>I have to create 3 tables in a database. So, i define the columns and rows of the table and execute the SQLite command. However, when I try to add some values to a table it gives me a runtime error. Contrary to this, when I only create one particular table and add values to it at runtime, thing seem to work properly. Down below is the database creation class:</p> <pre><code>public class StockDatabase extends SQLiteOpenHelper{ public static final String DATABASE_NAME="Accountancy"; public static final int DATABASE_VERSION=7; public static String createPurchaseTable= "CREATE TABLE stock (_id INTEGER PRIMARY KEY AUTOINCREMENT, item_name TEXT NOT NULL, quant INTEGER NOT NULL, Prate REAl NOT NULL, Srate REAL NOT NULL);"; public static String createSaleTable="CREATE TABLE i/o_register (_id INTEGER PRIMARY KEY AUTOINCREMENT, item_code INTEGER NOT NULL, quantity INTEGER NOT NULL, rate REAL NOT NULL);"; public static String createRegister="CREATE TABLE s/p_register (PartyName TEXT NOT NULL, range TEXT NOT NULL, date TEXT NOT NULL, type INTEGER NOT NULL);"; public StockDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL(createPurchaseTable); db.execSQL(createSaleTable); db.execSQL(createRegister); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS stock"); db.execSQL("DROP TABLE IF EXISTS i/o_register"); db.execSQL("DROP TABLE IF EXISTS s/p_register"); onCreate(db); } } </code></pre> <p>CASE: when only 'stock' table is created in the database. When i try adding some values to the 'stock' table things work perfect.</p> <p>CASE: when 3 tables are created in the database I try adding values to the stock table but it gives me a nullPointerException.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload