android - 将多个数据从 Android SQLLite 同步到 MariaDB
问题描述
我正在寻找一种简单的方法来将我SQLLite
存储的数据同步到MariaDB
SQL 数据库。
WebService
没问题,但我不知道一次获得多个数据同步。
我有DBAdapter
这个,id存储在sharedpreferences中:
public projekt getprojekt(int id){
// 2. build projekt query
Cursor cursor =
db.query(DATABASE_TABLE_P, // a. table
TABLE_P_COLUMNS_ALL, // b. column names
" id = ?", // c. selections
new String[] { String.valueOf(id) }, // d. selections args
null, // e. group by
null, // f. having
null, // g. order by
null); // h. limit
// 3. if we got results get the first one
if (cursor != null)
cursor.moveToFirst();
// 4. build projekt object
projekt projekt = new projekt();
projekt.setId(Integer.parseInt(cursor.getString(0)));
projekt.setKostenstelle(cursor.getString(1));
projekt.setAG(cursor.getString(2));
....
// 5. return projekt
return projekt;
}
和这个:
// Get Room List
public ArrayList<HashMap<String, String>> GetRaum(int pid){
ArrayList<HashMap<String, String>> raumList = new ArrayList<>();
String query = "SELECT * FROM "+ DATABASE_TABLE_R + " where pid = '"+ pid +"' order by "+KEY_R_BEZEICHNUNG+" asc";
Cursor cursor = db.rawQuery(query,null);
while (cursor.moveToNext()){
HashMap<String,String> raum = new HashMap<>();
raum.put("id",cursor.getString(cursor.getColumnIndex(KEY_M_ID)));
raum.put("bezeichnung",cursor.getString(cursor.getColumnIndex(KEY_M_BEZEICHNUNG)));
raumList.add(raum);
}
return raumList;
}
位我如何选择几个“房间”将其发送POST/JSON
到WebService
?
我当前发送数据的功能还没有完成......只是得到projekt_id
from sharedpreferences
。
public void postData() throws JSONException {
final SharedPreferences sharedPreferences = this.getSharedPreferences("de.dasal.dguvv3", Context.MODE_PRIVATE);
final Integer projektidsp = sharedPreferences.getInt("projekt_id", 0);
final projekt projekt = db.getprojekt(projektidsp);
}
如果您需要更多信息,请告诉我。这是我的第一个问题stackoverflow
。
解决方案
推荐阅读
- node.js - 套接字仅发送给一个用户
- php - “POST /?fgko=vkma”是有效的发布请求吗?
- c# - 需要多个 where 条件来使用 OR 运算符进行查询
- docker - 应用程序启动后出现 502 和 504 错误
- asp.net - 如何解决以下问题?存储过程
- javascript - React - 如何将 CSS 样式应用于 iframe 内容
- c# - 关于构建 WPF 表单以修改 userSettings 的建议
- smartsheet-api - 获取父行的子代
- condor - Condor中的墙时间扩展
- sql-server - 如何列出数据库中具有最大小数位的所有浮点列?