java - How to update multiple columns in one row using android sqlite database? -


i have android application stores location data. there 3 set of latitude , longitude in sqlite database. want take location's data 3 times , store database. in first step stores place, location address, latitude , longitude. second step without changing location , place taking latitude , longitude, stores next column first data.

http://i.stack.imgur.com/yratl.jpg

you can see in abouve image url there 3 sets of latitude , longitude. after getting first latitude , longitude want add second latitude , longitude column 'latitudey' , 'longitudey', next values 'latitudez' , 'longitudez'. coding ok there problem when second row adding. first latitude , longitude saving without mistakes in second , in third 1 copying upper values. can see in below given figure. how can solve this? database creation code given below. changes need here?

   public static final string database_name = "locationdb.db";    public static final string table_name = "locations";    public static final string ccolumn_id = "id";    public static final string column_lat = "latitude";    public static final string ccolumn_lon = "longitude";    public static final string column_lat2="latitudey";    public static final string column_lon2="longitudey";    public static final string column_lat3="latitudez";    public static final string column_lon3="longitudez";    public static final string column_loc = "location";    public static final string column_place="place";     private hashmap hp;     public sqlitecontroller(context context)    {     super(context, database_name, null,1);     // todo auto-generated constructor stub   }    @override   public void oncreate(sqlitedatabase db)   {     string query;     query = "create table locations ( id integer primary key, place text, location text, latitude text, longitude text, latitudey text, longitudey text, latitudez text, longitudez text)";     db.execsql(query);     }    @override   public void onupgrade(sqlitedatabase db, int oldversion, int newversion)    {     string query;     query = "drop table if exists locations";     db.execsql(query);     oncreate(db);    }    public boolean insertlocation(string place, string location, string latitude, string longitude )    {     sqlitedatabase database = this.getwritabledatabase();     contentvalues values = new contentvalues();     values.put("place", place);     values.put("location", location);     values.put("latitude",latitude);     values.put("longitude",longitude);     database.insert("locations", null, values);     database.close();     return true;    }    public boolean insertlocation2(string latitudey, string longitudey)   {      sqlitedatabase database = this.getwritabledatabase();     contentvalues values = new contentvalues();     values.put("latitudey",latitudey);     values.put("longitudey", longitudey);     database.update("locations", values, null,null);     database.close();     return true;    }    public boolean insertlocation3(string latitudez, string longitudez)   {     sqlitedatabase database = this.getwritabledatabase();     contentvalues values = new contentvalues();     values.put("latitudez", latitudez);     values.put("longitudez", longitudez);     database.update("locations", values, null, null);     database.close();     return true;    } 

you got indicate row want update :

public boolean insertlocation2(string place, string location, string latitudey, string longitudey) {     sqlitedatabase database = this.getwritabledatabase();     contentvalues values = new contentvalues();     values.put("latitudey",latitudey);     values.put("longitudey", longitudey);     database.update("locations", values, "place=? , location=?", new string[] {place, location});     database.close();     return true; } 

else rows updated !


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -