Table Is Not Deleted <p>i am trying to delete a table, and i followed this link <a href="http://www.techonthenet.com/sqlite/truncate.php" rel="nofollow">http://www.techonthenet.com/sqlite/truncate.php</a> as a tutorial. but when i execute the below code, for the first run, i expected the <code>sqliteFactory.getRowCount()</code> method will <code>return 0</code> rows as the method <code>sqliteFactory.deleteTable(SysConsts.SQLITE_DATABASE_TABLE_NAME);</code> was just called before it, but what i received is a <code>rowCount</code> which is not zero.</p> <p>in the second run of the same code, i expected the <code>sqliteFactory.CreateTable(SysConsts.SQLITE_DATABASE_TABLE_NAME);</code> to display <code>Log.i(TAG, "CreateTable", "table: ["+tableName+"] does not exist, will be created");</code> as the table should have been deleted, but i received <code>Log.i(TAG, "CreateTable", "table: ["+tableName+"] already exists.");</code></p> <p>kindly please let me know how why the table is not deleted? and should i do <code>commit</code> after deletion?</p> <p><strong>main code</strong>:</p> <pre><code>public static void main(String[] args) throws SQLException, ClassNotFoundException { SQLiteFactory sqliteFactory = new SQLiteFactory(); sqliteFactory.newSQLiteConn(SysConsts.SQLITE_DATABASE_NAME); sqliteFactory.CreateTable(SysConsts.SQLITE_DATABASE_TABLE_NAME); sqliteFactory.insertRecord(new Record("001", "55.07435", "8.79047", "c:\\bremen_0.xml")); Log.d(TAG, "main", "rowCount: "+sqliteFactory.getRowCount()); //sqliteFactory.selectAll(); //sqliteFactory.getNodeID("53.074415", "8.788047"); sqliteFactory.selectXMLPathFor("53.074415", "8.788047"); Log.d(TAG, "", ""+sqliteFactory.getRowCountLatLngFor("53.074415", "8.788047")); Log.d(TAG, "", ""+sqliteFactory.getRowCountNodeIDFor("001")); Log.d(TAG, "", ""+sqliteFactory.getRowCountXMLPathFor("c:\\brem_0.xml")); sqliteFactory.deleteTable(SysConsts.SQLITE_DATABASE_TABLE_NAME); Log.d(TAG, "main", "rowCount: "+sqliteFactory.getRowCount()); } </code></pre> <p><strong>CreateTable</strong>:</p> <pre><code>public void CreateTable(String tableName) throws SQLException, ClassNotFoundException { if (!this.isTableExists(tableName)) { Log.i(TAG, "CreateTable", "table: ["+tableName+"] does not exist, will be created"); Connection conn = this.getConnection(); Statement stmt = conn.createStatement(); stmt.executeUpdate(this.sqlTable); stmt.close(); conn.close(); } else { Log.i(TAG, "CreateTable", "table: ["+tableName+"] already exists."); return; } } </code></pre> <p><strong>isTableExists</strong>:</p> <pre><code>private boolean isTableExists(String tableName) throws ClassNotFoundException, SQLException { Connection conn = this.getConnection(); DatabaseMetaData dbMeta = conn.getMetaData(); ResultSet resSet = dbMeta.getTables(null, null, tableName, null); boolean exists = false; if (resSet.next()) { exists = true; } else { exists = false; } resSet.close(); conn.close(); return exists; } </code></pre> <p><strong>deleteTable</strong>:</p> <pre><code>public void deleteTable(String tableName) throws ClassNotFoundException, SQLException { if (this.isTableExists(tableName)) { Log.i(TAG, "deleteTable", "table: ["+tableName+"] already exists, and will be deleted."); Connection conn = this.getConnection(); PreparedStatement ps = conn.prepareStatement("delete from "+this.TABLE_NAME); ps.close(); conn.close(); } else { Log.i(TAG, "deleteTable", "table: ["+tableName+"] does not exist, can't be deleted."); return; } } </code></pre> <p><strong>getRowCount</strong>:</p> <pre><code>public int getRowCount() throws SQLException, ClassNotFoundException { Connection conn = this.getConnection(); Statement stmt= conn.createStatement(); ResultSet resSet = stmt.executeQuery("SELECT COUNT(*) AS rowCount FROM "+TABLE_NAME+";"); int cnt = resSet.getInt("rowCount"); resSet.close(); stmt.close(); conn.close(); return cnt; } </code></pre>