Android 要将数据从sqlite数据库传输到服务器吗

Android 要将数据从sqlite数据库传输到服务器吗,android,Android,我在android中开发了一个离线数据输入应用程序,用户可以输入所有细节,这些细节将保存在sqlite数据库中 最后,我想将数据从sqlite数据库传输到一个服务器,该服务器将数据存储在PostgreSQL数据库中。根据我的要求,我没有找到任何好的答案。///这在数据库类中是怎么写的 /// whrite this in database class public Cursor getAllData(String emailid) { String query

我在android中开发了一个离线数据输入应用程序,用户可以输入所有细节,这些细节将保存在sqlite数据库中

最后,我想将数据从sqlite数据库传输到一个服务器,该服务器将数据存储在PostgreSQL数据库中。根据我的要求,我没有找到任何好的答案。

///这在数据库类中是怎么写的
  /// whrite this in database class
   public Cursor getAllData(String emailid) {
            String query = "select * from "+ORDERHISTORY_TABLE+" Where "+ ACCOUNT + "= '"+ emailid +"' ORDER BY "+ NOTIFICATION_RID +" ASC ";
            SQLiteDatabase db = this.getReadableDatabase();
            Cursor cursor = db.rawQuery(query, null);
            return cursor;
        }
////write this in java class
                   {
     Cursor cursor = helpher.getAllData(Emailid);//cursor hold all your data
                    arr = new JSONArray();
                    if (cursor.moveToFirst()){
                        do {
                            jobj = new JSONObject();
                            try {
                                jobj.put("Order_id", cursor.getString(1));
                                jobj.put("Order_tittle",  cursor.getString(2));
                                jobj.put("Order_quantity",  cursor.getString(3));
                                jobj.put("Order_price",  cursor.getString(5));
                                jobj.put("Order_totalprice",  cursor.getString(4));
                                jobj.put("Order_image",  cursor.getString(6));
                                jobj.put("Address1",  cursor.getString(8));
                                jobj.put("Address2",  cursor.getString(9));
                                jobj.put("Name",  cursor.getString(10));
                                jobj.put("Phone",  cursor.getString(11));
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            arr.put(jobj);
                        }while (cursor.moveToNext());
                    }
                    jobj = new JSONObject();
                    try {
                        jobj.put("data", arr);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    String st = jobj.toString();
              Log.i("jhfg",""+st);




                    try {
                        JsonObjectRequest request_json = new JsonObjectRequest("url", new JSONObject(st),
                                new Response.Listener<JSONObject>() {
                                    @Override
                                    public void onResponse(JSONObject response) {
                                        //Process os success response
                                    }
                                }, new Response.ErrorListener() {
                            @Override
                            public void onErrorResponse(VolleyError error) {
                                VolleyLog.e("Error: ", error.getMessage());
                            }
                        });
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

    // add the request object to the queue to be executed
    //                ApplicationController.getInstance().addToRequestQueue(request_json);

            }
公共游标getAllData(字符串emailid){ String query=“从“+ORDERHISTORY\u TABLE+”中选择*,其中“+ACCOUNT+”='”+emailid+“'orderby”+NOTIFICATION\u RID+“ASC”; SQLiteDatabase db=this.getReadableDatabase(); Cursor Cursor=db.rawQuery(查询,空); 返回光标; } ////在java类中编写此代码 { Cursor Cursor=helpher.getAllData(Emailid);//Cursor保存所有数据 arr=新的JSONArray(); if(cursor.moveToFirst()){ 做{ jobj=新的JSONObject(); 试一试{ put(“Order_id”,cursor.getString(1)); jobj.put(“Order_title”,cursor.getString(2)); jobj.put(“订单数量”,cursor.getString(3)); jobj.put(“订单价格”,cursor.getString(5)); jobj.put(“Order_totalprice”,cursor.getString(4)); put(“Order_image”,cursor.getString(6)); jobj.put(“Address1”,cursor.getString(8)); put(“Address2”,cursor.getString(9)); jobj.put(“Name”,cursor.getString(10)); jobj.put(“Phone”,cursor.getString(11)); }捕获(JSONException e){ e、 printStackTrace(); } arr.put(jobj); }while(cursor.moveToNext()); } jobj=新的JSONObject(); 试一试{ jobj.put(“数据”,arr); }捕获(JSONException e){ e、 printStackTrace(); } 字符串st=jobj.toString(); Log.i(“jhfg”和“+st”); 试一试{ JsonObjectRequest\u json=新的JsonObjectRequest(“url”,新的JSONObject(st), 新的Response.Listener(){ @凌驾 公共void onResponse(JSONObject响应){ //处理操作系统成功响应 } },new Response.ErrorListener(){ @凌驾 公共无效onErrorResponse(截击错误){ e(“Error:,Error.getMessage()); } }); }捕获(JSONException e){ e、 printStackTrace(); } //将请求对象添加到要执行的队列中 //ApplicationController.getInstance().addToRequestQueue(请求\u json); }
我看不出有什么好问题。问题到底是什么?无法从SQLite读取数据?你不能将数据发送到服务器?事实上,我必须将整个数据从sqlite数据库发送到服务器上面的代码是我使用的,但我在上面的代码上遇到问题,请帮助我,请将所有代码放在你的帖子中。正如在评论中一样,它是不可读的。你应该在你的帖子里描述你的问题。