title: How to create multiple tables and insert values in columns and retrieve data in list in SQLite?
body: <p>I am making app to insert data and retrieve data in list form.. but i dont get any list and get blank page. The logcat is not giving any error.</p>
  
  <p>Code: Components.java</p>
  
  <pre><code>  public class Components extends Activity implements OnClickListener {
        Button b1,b2,b3,b4;
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_components);        
              Intent i = getIntent();
              b1= (Button) findViewById(R.id.mobile);
              b2= (Button) findViewById(R.id.camera); 
              b3= (Button) findViewById(R.id.computer);
              b4= (Button) findViewById(R.id.bike);        
              b1.setOnClickListener(this);                
          }
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if (v.getId() == R.id.mobile) {
                             Sqlite sqll = new Sqlite(this);
               sqll.insertMobile();
                  Intent h = new Intent(Components.this, Mobile.class);
                  startActivity(h);
              }
          }   
      }
  </code></pre>
  
  <p>Code: Sqlite.java</p>
  
  <pre><code>public class Sqlite extends SQLiteOpenHelper {
      public static final String DB_NAME = "Get_Price";
      public static final int DB_VERSION = 1;
  
      public static final String MTABLE_NAME = "mobile";
      public static final String COLUMN_MNAME= "mname";
      public static final String COLUMN_MMODEL= "model";
      public static final String COLUMN_MPRICE= "mprice";
      public static final String COLUMN_MCAMERA= "mcamera";
  
      public static final String CTABLE_NAME = "camera";
      public static final String COLUMN_CNAME= "cname";
      public static final String COLUMN_CMODEL= "cmodel";
      public static final String COLUMN_CPRICE= "cprice";
      public static final String COLUMN_CCAMERA= "ccamera";
  
      public static final String BTABLE_NAME = "bike";
      public static final String COLUMN_BNAME= "bname";
      public static final String COLUMN_BMODEL= "bmodel";
      public static final String COLUMN_BPRICE= "bprice";
  
      public static final String LTABLE_NAME = "laptop";
      public static final String COLUMN_LNAME= "lname";
      public static final String COLUMN_LMODEL= "lmodel";
      public static final String COLUMN_LPRICE= "lprice";
  
      public Sqlite(Context context) {
          super(context, DB_NAME, null, 1);
          // TODO Auto-generated constructor stub
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          // TODO Auto-generated method stub
          String CreateTableMoblie = "CREATE TABLE " + MTABLE_NAME + " ( " + COLUMN_MNAME + " TEXT, " + COLUMN_MMODEL + " TEXT "
                                                                     + COLUMN_MPRICE + " TEXT, " + COLUMN_MCAMERA + " TEXT " + " ) ";
  
          db.execSQL(CreateTableMoblie);
  
          String CreateTableCamera = "CREATE TABLE " + CTABLE_NAME + " ( " + COLUMN_CNAME + " TEXT, " + COLUMN_CMODEL + " TEXT "
                                                                     + COLUMN_CPRICE + " TEXT, " + COLUMN_CCAMERA + " TEXT " + " ) ";
          db.execSQL(CreateTableCamera);
  
          String CreateTableBike = "CREATE TABLE " + BTABLE_NAME + " ( " + COLUMN_BNAME + " TEXT, " + COLUMN_BMODEL + " TEXT "
                                                                      + COLUMN_BPRICE + " TEXT " + " ) ";
          db.execSQL(CreateTableBike);
  
          String CreateTableLaptop = "CREATE TABLE " + LTABLE_NAME + " ( " + COLUMN_LNAME + " TEXT, " + COLUMN_LMODEL + " TEXT "
                  + COLUMN_LPRICE + " TEXT " + " ) ";
          db.execSQL(CreateTableLaptop);
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          // TODO Auto-generated method stub
          db.execSQL("DROP TABLE IF EXISTS " +MTABLE_NAME );  
          db.execSQL("DROP TABLE IF EXISTS " +CTABLE_NAME );
          db.execSQL("DROP TABLE IF EXISTS " +BTABLE_NAME );  
          db.execSQL("DROP TABLE IF EXISTS " +LTABLE_NAME );
          onCreate(db);
      }
      public long insertMobile() {
          SQLiteDatabase database = this.getWritableDatabase();
          ContentValues values = new ContentValues();
          values.put("mname","samsung" );
          values.put("mmodel","samsung2s" );
          values.put("mprice",5000 );
          values.put("mcamera","yes" );
          database.insert("mobile", null, values);
  
          values.put("mname","nokia" );                       
          values.put("mmodel","nokia1100" );
          values.put("mprice",2000 );                       
          values.put("mcamera","no" );
          database.insert("mobile", null, values);
  
          values.put("mname","sony xperia" );
          values.put("mmodel","xperia100" ); 
          values.put("mprice","30000" );
          values.put("mcamera","yes" );  
          return database.insert("mobile", null, values);             
      }  
  }
  </code></pre>
  
  <p>Code:Mobile.java</p>
  
  <pre><code>public class Mobile extends ListActivity {
      Sqlite sql = new Sqlite(this);
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_mobile);
          Intent h= getIntent();             
           ArrayList&lt;HashMap&lt;String, String&gt;&gt; MobileList = getAllMobiles();
       ListAdapter adapter = new SimpleAdapter(Mobile.this, MobileList, R.layout.mobile_names,
               new String[] {Sqlite.COLUMN_MNAME}, new int[] {R.id.nameofmobile});
       setListAdapter(adapter);       
      }
      public ArrayList&lt;HashMap&lt;String,String&gt;&gt; getAllMobiles() {
          ArrayList &lt;HashMap&lt;String,String&gt;&gt; wordlist;
          wordlist= new ArrayList &lt;HashMap&lt;String, String&gt;&gt;();
          String Query = "SELECT * FROM mobile";  
  
          SQLiteDatabase database = sql.getWritableDatabase();
  
          Cursor cursor = database.rawQuery(Query, null);
          if (cursor.moveToFirst()) {
              do {
              HashMap&lt;String,String&gt; map = new HashMap&lt;String, String&gt;();
              map.put(Sqlite.COLUMN_MNAME, cursor.getString(0));
              map.put(Sqlite.COLUMN_MMODEL, cursor.getString(1));
              map.put(Sqlite.COLUMN_MPRICE, cursor.getString(2));
              map.put(Sqlite.COLUMN_MCAMERA, cursor.getString(3));
              wordlist.add(map);
              } while (cursor.moveToNext());
          }
          return wordlist;        
      }
  }
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>04-03 12:11:32.774: E/SQLiteLog(609): (1) table mobile has no column named mprice
  04-03 12:11:32.804: E/SQLiteDatabase(609): Error inserting mname=samsung mcamera=yes mprice=5000 mmodel=samsung2s
  04-03 12:11:32.804: E/SQLiteDatabase(609): android.database.sqlite.SQLiteException: table mobile has no column named mprice (code 1): , while compiling: INSERT INTO mobile(mname,mcamera,mprice,mmodel) VALUES (?,?,?,?)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteStatement.&lt;init&gt;(SQLiteStatement.java:31)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at com.example.get_price.Sqlite.insertMobile(Sqlite.java:85)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at com.example.get_price.Components.onClick(Components.java:32)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.view.View.performClick(View.java:4084)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.view.View$PerformClick.run(View.java:16966)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.os.Handler.handleCallback(Handler.java:615)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.os.Handler.dispatchMessage(Handler.java:92)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.os.Looper.loop(Looper.java:137)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at java.lang.reflect.Method.invokeNative(Native Method)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at java.lang.reflect.Method.invoke(Method.java:511)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  04-03 12:11:32.804: E/SQLiteDatabase(609):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I am getting this error..</p>