1

I am having problem while inserting 6th record to SpatiaLite table it auto deletes 5th record, and after that it is ok.

I am using SpatiaLite database to insert some polygon using Google Maps API in an Android application.

My insertion code is like:

      String polyPoints = "POLYGON((";
        if (listofpoints.size() != 0) {
            for (int i = 0; i < listofpoints.size(); i++) {
                polyPoints += listofpoints.get(i).longitude + " " + listofpoints.get(i).latitude;
                if (i < listofpoints.size() - 1) {
                    polyPoints += ", ";
                }
            }
            polyPoints += ")) ";
        }

        try {

            Stmt stmt01 = null;
            stmt01 = database.prepare("INSERT INTO " + table + " (id, username, cutarea, createdate, rosen, range, treecat, fields, GEOMETRY) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?,  ST_GeomFromText('" + polyPoints + "', 4326));");
//                stmt01 = database.prepare("INSERT INTO " + table + " (id, username, cutarea, createdate, rosen, range, treecat, fields, GEOMETRY) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?,   MakePoint(" + listofpoints.get(i).longitude + ", " + listofpoints.get(i).longitude + ", 4326));");

            stmt01.bind(1, username);
            stmt01.bind(2, cutarea);
            stmt01.bind(3, createdate);
            stmt01.bind(4, rosen);
            stmt01.bind(5, range);
            stmt01.bind(6, treecat);
            stmt01.bind(7, fields);

            stmt01.step();
            stmt01.close();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

but while I try to insert polygons in the loop it is ok.

What should I try next?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.