我正在開發一個geofencing程序,我需要保存用戶的路徑。存儲位置數據的最佳方式 - Android
到目前爲止,我在SharedPreferences中存儲了一組字符串,每個X min數據將被髮送到服務器並清除所有變量,所以我不認爲會有存儲問題。
我想知道是否有最好的方法來做到這一點。
UPDATE: 只要SharedPreferences沒有支持列表我會遵循@ chiastic-security的意見,我將創建一個類將有浮點類型和時間戳點的點,然後我將它添加到一個組。
這是我的代碼示例:
SharedPreferences prefs = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
ArrayList<String> path;
public void updatePath(Points point){
path.add(point);
Set<String> mySet = new HashSet<String>(path);
prefs.edit().putStringSet("path", mySet).commit();
}
和累計積分類
public class Points {
private Double[] coordinates;
private long timestamp;
public Points(Double[] coordinates){
this.coordinates = coordinates;
this.timestamp = System.currentTimeMillis();
}
如果需要長時間存儲,這可能是一個非常值得關注的問題,但在這種情況下,我們正試圖將信息存儲一段確定的時間。不管怎麼說,還是要謝謝你! – kike 2014-10-07 08:34:07