android - 将接收到的坐标存储到 SQLite 数据库
问题描述
我的电话号码收到 LAT 和 LONG 的短信。示例文本:
纬度:23.424076 经度:53.847818
我看到了一个关于如何将这些数据传递到 SQLite 数据库的教程。但是,它会读取所有传入的消息。我想从一个数字中获取这些数据。
一张桌子上有 3 列。一个用于地址、日期和正文。我希望我的应用程序识别正文(消息)是否有纬度和经度,并获取浮点数,并将其放在我桌子上的单独列上。
这很令人困惑。你能建议我应该怎么做吗?
解决方案
考虑到您将始终收到消息文本为“LAT:”和“LONG:”
String str = "LAT: 23.424076 LONG: 53.847818";
String[] splits = str.split("LAT: | LONG: ");
//test with
for(String s : splits)
System.out.println(s);
//Do your necessary jobs with the values over here