如何保存在android的sqlite的经纬度GPS? [英] How to save longitude latitude gps in sqlite android?

查看:1047
本文介绍了如何保存在android的sqlite的经纬度GPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何保存协调数据库SQLite的改变位置的GPS经纬度每个给定一个小时。

下面是我的code,

 公共无效onLocationChanged(决赛地点){
        Log.e(全球定位系统,纬度+ location.getLatitude()+等经度+ location.getLongitude());
         BDHandler =新数据库处理器(NULL);
         DB = BDHandler.getWritableDatabase();
     主题日=新的Thread(){
         公共无效的run()
         {         ContentValues​​值=新ContentValues​​();
            value.put(经度,Double.toString(location.getLatitude()));
            value.put(纵横,Double.toString(location.getLongitude()));
            {尝试
            {
         而(真)
         {
             视频下载(360000);
             {
                 db.insert(表格名,空,价值);
             }
         }            }
            赶上(例外五)
            {
                e.printStackTrace();
            }
            }
         }         };
            th.start();
        }


解决方案

您正在存储纬度/只要它至少使用字符串TRIPPLE所需的空间。存储为float或为int更好,通过与1E7 multiplyimg。

How to save coordinate gps latitude and longitude of the location changed in the database sqlite each given one hour.

Here is my code,

public void onLocationChanged(  final Location location) { 
        Log.e("GPS", "Latitude " + location.getLatitude() + " et longitude " + location.getLongitude());
         BDHandler = new DatabaseHandler(null);
         db = BDHandler.getWritableDatabase();
     Thread th= new Thread() {
         public void run()
         {

         ContentValues value = new ContentValues();
            value.put("LONGITUDE", Double.toString(location.getLatitude()));
            value.put("LATITUDE", Double.toString( location.getLongitude()));
            { try
            {
         while(true)
         {
             Thread.sleep(360000);
             {
                 db.insert("Table_name", null, value);
             }
         }

            }
            catch(Exception e) 
            {
                e.printStackTrace();
            } 
            }
         }

         };
            th.start();


        }

解决方案

You are storing lat/long as string which uses at least tripple the space needed. store them as float or better as int, by multiplyimg with 1e7.

这篇关于如何保存在android的sqlite的经纬度GPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆