SQLite不断扩张

SQLite不断扩张,sqlite,blackberry,Sqlite,Blackberry,我是黑莓开发和这个网站的新手。现在,我正在开发一个从json服务检索数据的应用程序。在我的应用程序中,我应该将数据解析到数据库中,并将其保存在四个表中。我已经解析了数据,并且成功地创建了数据库并添加了第一个表和第二个表 我现在面临的问题是,我数据库中的第二个表不断扩展。我在sql浏览器中检查了数据库,发现每次单击应用程序图标,它都会再次将700行添加到表中。(例如,700变为1400) (只有第二张桌子,第一张桌子工作得很好) 先谢谢你 这是我的代码: public void parseJSON

我是黑莓开发和这个网站的新手。现在,我正在开发一个从json服务检索数据的应用程序。在我的应用程序中,我应该将数据解析到数据库中,并将其保存在四个表中。我已经解析了数据,并且成功地创建了数据库并添加了第一个表和第二个表

我现在面临的问题是,我数据库中的第二个表不断扩展。我在sql浏览器中检查了数据库,发现每次单击应用程序图标,它都会再次将700行添加到表中。(例如,700变为1400)

(只有第二张桌子,第一张桌子工作得很好)

先谢谢你

这是我的代码:

public void parseJSONResponceInBB(String jsonInStrFormat)
{
    try {
        JSONObject json = newJSONObject(jsonInStrFormat);
        JSONArray jArray = json.getJSONArray("tables");

        for (inti = 0; i < jArray.length(); i++) {
            //Iterate through json array
            JSONObject j = jArray.getJSONObject(i);
            if (j.has("Managers")) {
                add(new LabelField("Managers has been added to the database"));

                JSONArray j2 = j.getJSONArray("Managers");

                for (intk = 0; k < j2.length(); ++k) {
                    JSONObject MangersDetails = j2.getJSONObject(k);
                    if (MangersDetails.has("fName")) {
                        try {
                            URI myURI =
                                URI.create
                                ("file:///SDCard/Databases/SQLite_Guide/"
                                 + "MyTestDatabase.db");

                            d = DatabaseFactory.openOrCreate(myURI);

                            Statement st =
                                d.createStatement
                                ("CREATE TABLE Managers ( "
                                 + "fName TEXT, " +
                                 "lName TEXT, " + "ID TEXT," + "Type TEXT )");

                            st.prepare();
                            st.execute();
                            st.close();
                            d.close();
                        }
                        catch(Exception e) {
                            System.out.println(e.getMessage());
                            e.printStackTrace();
                        }

                        try {
                            URI myURI =
                                URI.create
                                ("file:///SDCard/Databases/SQLite_Guide/"
                                 + "MyTestDatabase.db");

                            d = DatabaseFactory.open(myURI);

                            Statement st =
                                d.createStatement
                                ("INSERT INTO Managers(fName, lName, ID, Type) "
                                 + "VALUES (?,?,?,?)");

                            st.prepare();

                            for (intx = 0; x < j2.length(); x++) {
                                JSONObject F = j2.getJSONObject(x);
                                //add(new LabelField ("f"));
                                st.bind(1, F.getString("fName"));
                                st.bind(2, F.getString("lName"));
                                st.bind(3, F.getString("ID"));
                                st.bind(4, F.getString("Type"));
                                st.execute();
                                st.reset();
                            }
                            d.close();
                        }
                        catch(Exception e) {
                            System.out.println(e.getMessage());
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
    catch(JSONException e) {
        e.printStackTrace();
    }
}

    //Owners method
public voidparseJSONResponceInBB1(String jsonInStrFormat)
{
    try {
        JSONObject json = newJSONObject(jsonInStrFormat);
        JSONArray jArray = json.getJSONArray("tables");

        for (inti = 0; i < jArray.length(); i++) {
            //Iterate through json array
            JSONObject j = jArray.getJSONObject(i);
            if (j.has("Owners")) {
                add(new LabelField("Owners has been added to the database"));
                JSONArray j2 = j.getJSONArray("Owners");
                for (intk = 0; k < j2.length(); ++k) {
                    JSONObject OwnersDetails = j2.getJSONObject(k);
                    if (OwnersDetails.has("fName")) {
                        try {
                            Statement st =
                                d.createStatement
                                ("CREATE TABLE Owners ( "
                                 + "fName TEXT, " +
                                 "lName TEXT, " + "ID TEXT," + "Type TEXT )");
                            st.prepare();
                            st.execute();
                            st.close();
                            d.close();
                        }
                        catch(Exception e) {
                            System.out.println(e.getMessage());
                            e.printStackTrace();
                        }

                        try {
                            Statement st =
                                d.createStatement
                                ("INSERT INTO Owners(fName, lName, ID, Type) "
                                 + "VALUES (?,?,?,?)");

                            st.prepare();
                            for (intx = 0; x < j2.length(); x++) {
                                JSONObject F = j2.getJSONObject(x);
                                //add(new LabelField ("f"));
                                st.bind(1, F.getString("fName"));
                                st.bind(2, F.getString("lName"));
                                st.bind(3, F.getString("ID"));
                                st.bind(4, F.getString("Type"));
                                st.execute();
                                st.reset();
                            }
                            d.close();
                        }
                        catch(Exception e) {
                            System.out.println(e.getMessage());
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
    catch(JSONException e) {
        e.printStackTrace();
    }
}
public void parseJSONResponceInBB(字符串jsonInStrFormat)
{
试一试{
JSONObject json=newJSONObject(jsonInStrFormat);
JSONArray jArray=json.getJSONArray(“表”);
对于(inti=0;i