Android 合作伙伴; } //获取所有posx、posy和信息 公共阵列列表getAllPos_info(){ ArrayList coordList=新的ArrayList(); //选择所有查询 String selectQuery=“SELECT*FROM”+表格位置; SQLiteDatabase db=this.getWritableDatabase(); Cursor Cursor=db.rawQuery(selectQuery,null); //循环遍历所有行并添加到列表 if(cursor.moveToFirst()){ 做{ 位置站位置站=新位置站(); pos_station.setOrder(cursor.getString(1)); pos_station.setLibelle(cursor.getString(2)); pos_station.setPosX(cursor.getString(3)); pos_station.setPosY(cursor.getString(4)); //向列表中添加位置 合作列表。添加(pos_站); }while(cursor.moveToNext()); } cursor.close(); db.close(); //返回联系人列表 返回合作列表; } }

Android 合作伙伴; } //获取所有posx、posy和信息 公共阵列列表getAllPos_info(){ ArrayList coordList=新的ArrayList(); //选择所有查询 String selectQuery=“SELECT*FROM”+表格位置; SQLiteDatabase db=this.getWritableDatabase(); Cursor Cursor=db.rawQuery(selectQuery,null); //循环遍历所有行并添加到列表 if(cursor.moveToFirst()){ 做{ 位置站位置站=新位置站(); pos_station.setOrder(cursor.getString(1)); pos_station.setLibelle(cursor.getString(2)); pos_station.setPosX(cursor.getString(3)); pos_station.setPosY(cursor.getString(4)); //向列表中添加位置 合作列表。添加(pos_站); }while(cursor.moveToNext()); } cursor.close(); db.close(); //返回联系人列表 返回合作列表; } },android,sqlite,Android,Sqlite,我的主要活动就像我想把数据放入数据库一样 DatabaseHandlerStation db_pos_station= new DatabaseHandlerStation(this); JSONArray jsonArret = new JSONArray(Data); for(int i=0;i < jsonArret.length();i++) { JSONObject json

我的主要活动就像我想把数据放入数据库一样

DatabaseHandlerStation db_pos_station= new DatabaseHandlerStation(this);

JSONArray jsonArret = new JSONArray(Data);
                        for(int i=0;i < jsonArret.length();i++) {
                            JSONObject jsonobj = jsonArret.getJSONObject(i);
                            String order=jsonobj.getString(TAG_ORDER);
                            String libel=jsonobj.getString(TAG_LIBELLE);
                            String posx=jsonobj.getString(TAG_POSX_STATION);
                            String posy=jsonobj.getString(TAG_POSY_STATION);
                            db_pos_station.addPosition(new Position_Station(order,libel,posx,posy));  
DatabaseHandlerStation db\u pos\u station=新的DatabaseHandlerStation(此);
JSONArray jsonArret=新的JSONArray(数据);
for(int i=0;i

谢谢

顺序
是一个SQL关键字。重命名列,或在
中引用它“双引号”

顺序是一个保留的SQL字,重命名条目,它将正常工作

顺序是保留字。。。。。
public class DatabaseHandlerStation extends SQLiteOpenHelper {

    // Database Version
    private static final int DATABASE_VERSION = 2;

    // Database Name
    private static final String DATABASE_NAME = "POSITIONSSTATIONMANAGER";

    // Contacts table name
    private static final String TABLE_POSITIONS = "position_arret";

    // Table Columns names
    private static final String KEY_ID = "id";
    private static final String KEY_LIBELLE = "libelle";
    private static final String KEY_ORDER="order";
    private static final String KEY_POSX = "posx";
    private static final String KEY_POSY="posy";

    public DatabaseHandlerStation(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    // Creating Tables
    @Override
    public void onCreate(SQLiteDatabase db) {

        String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_POSITIONS + "("
                + KEY_ID + " INTEGER PRIMARY KEY,"
                + KEY_ORDER + " TEXT,"
                + KEY_LIBELLE + " TEXT,"
                + KEY_POSX + " TEXT,"
                + KEY_POSY + " TEXT" +")";
        db.execSQL(CREATE_CONTACTS_TABLE);
    }

    // Upgrading database
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // Drop older table if existed
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_POSITIONS);

        // Create tables again
        onCreate(db);
    }

    /**
     * All CRUD(Create, Read, Update, Delete) Operations
     */
    //delete all rows in table
    public void deleteAll()
    {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_POSITIONS,null,null);
        //   db.execSQL("DROP TABLE IF EXISTS " + TABLE_POSITIONS);
        //   db.execSQL("TRUNCATE TABLE " + TABLE_POSITIONS);
        db.close();
    }

    // Adding new position
    void addPosition(Position_Station p_station) {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues values = new ContentValues();
        values.put(KEY_ORDER, p_station.getOrder());
        values.put(KEY_LIBELLE, p_station.getLibelle());
        values.put(KEY_POSX, p_station.getPosX()); // Laltitude Pos x
        values.put(KEY_POSY, p_station.getPosY()); // Longitude Pos y


        // Inserting Row
        db.insert(TABLE_POSITIONS, null, values);
        db.close(); // Closing database connection
    }



    // Getting All Positions
    public List<Position_Station> getAllPositions() {
        List<Position_Station> positionList = new ArrayList<Position_Station>();
        // Select All Query
        String selectQuery = "SELECT  * FROM " + TABLE_POSITIONS;

        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        // looping through all rows and adding to list
        if (cursor.moveToFirst()) {
            do {
                Position_Station pos_station = new Position_Station();
                pos_station.setID(Integer.parseInt(cursor.getString(0)));
                pos_station.setOrder(cursor.getString(1));
                pos_station.setLibelle(cursor.getString(2));
                pos_station.setPosX(cursor.getString(3));
                pos_station.setPosX(cursor.getString(4));
                // Adding contact to list
                positionList.add(pos_station);
            } while (cursor.moveToNext());
        }
        cursor.close();
        db.close();
        // return contact list
        return positionList;
    }

    // Updating single position
    public int updatePosition_Station(Position_Station position) {
        SQLiteDatabase db = this.getWritableDatabase();

        ContentValues values = new ContentValues();
        values.put(KEY_ORDER, position.getOrder());
        values.put(KEY_LIBELLE, position.getLibelle());
        values.put(KEY_POSX, position.getPosX());
        values.put(KEY_POSY, position.getPosY());

        // updating row
        return db.update(TABLE_POSITIONS, values, KEY_ID + " = ?",
                new String[] { String.valueOf(position.getID()) });
    }

    // Deleting single position
    public void deletePosition(Position_Station position) {
        SQLiteDatabase db = this.getWritableDatabase();
        db.delete(TABLE_POSITIONS, KEY_ID + " = ?",
                new String[] { String.valueOf(position.getID()) });
        db.close();
    }

    // Getting Positions Count
    public int getPositionsCount() {
        String countQuery = "SELECT  * FROM " + TABLE_POSITIONS;
        int i;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(countQuery, null);
        i=cursor.getCount();
        cursor.close();
        // return count
        return i;   
    }



    // Getting all posx and posy 
    public ArrayList<LatLng> getAllPos() {
        ArrayList<LatLng> coordList = new ArrayList<LatLng>();
        // Select All Query
        String selectQuery = "SELECT  * FROM " + TABLE_POSITIONS;

        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        // looping through all rows and adding to list
        if (cursor.moveToFirst()) {
            do {
                //  Position position = new Position();
                //  position.setPosX(cursor.getString(1));
                //  position.setPosY(cursor.getString(2));
                // Adding position to list
                coordList.add(new LatLng(Double.parseDouble(cursor.getString(3))
                        ,Double.parseDouble(cursor.getString(4))));
            } while (cursor.moveToNext());
        }
        cursor.close();
        db.close();
        // return contact list
        return coordList;
    }

    // Getting all posx, posy, and information
    public ArrayList<Position_Station> getAllPos_info() {
        ArrayList<Position_Station> coordList = new ArrayList<Position_Station>();
        // Select All Query
        String selectQuery = "SELECT  * FROM " + TABLE_POSITIONS;

        SQLiteDatabase db = this.getWritableDatabase();
        Cursor cursor = db.rawQuery(selectQuery, null);

        // looping through all rows and adding to list
        if (cursor.moveToFirst()) {
            do {
                Position_Station pos_station = new Position_Station();
                pos_station.setOrder(cursor.getString(1));
                pos_station.setLibelle(cursor.getString(2));
                pos_station.setPosX(cursor.getString(3));
                pos_station.setPosY(cursor.getString(4));
                // Adding position to list
                coordList.add(pos_station);
            } while (cursor.moveToNext());
        }
        cursor.close();
        db.close();
        // return contact list
        return coordList;
    }
}
DatabaseHandlerStation db_pos_station= new DatabaseHandlerStation(this);

JSONArray jsonArret = new JSONArray(Data);
                        for(int i=0;i < jsonArret.length();i++) {
                            JSONObject jsonobj = jsonArret.getJSONObject(i);
                            String order=jsonobj.getString(TAG_ORDER);
                            String libel=jsonobj.getString(TAG_LIBELLE);
                            String posx=jsonobj.getString(TAG_POSX_STATION);
                            String posy=jsonobj.getString(TAG_POSY_STATION);
                            db_pos_station.addPosition(new Position_Station(order,libel,posx,posy));