How to connect Android with Oracle database?

前端 未结 1 961
傲寒
傲寒 2021-01-27 11:28

I am new to android development. I want to develop a android application that update data from a oracle database. Could anyone help me out?

Thanks in advance.

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 11:53

    Use Apache Server to connect android to pc

    In php.ini open oci8.dll

    in htdocs make php file. Your php code is

    
    

    In android:

    public class UploadActivity extends AsyncTask {
    Context context;
    
    String result;
    
    public UploadActivity(Context context) {
        this.context = context;
    }
    
    @SuppressWarnings("static-access")
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    
    
    }
    
    @Override
    protected String doInBackground(Void... params) {
        // TODO Auto-generated method stub
    
    
        final List> postParameters = new ArrayList<>();
    
    
    
    
            for (int i = 0; i < activity[0].length; i++) {
    
                //postParameters.add(new Pair<>("var1", activity[i][0]);
    
                result = null;
    
    
                try {
    
                    String response = CustomHttpClient.execute(
                            URL + "Your_php.php", postParameters);
                    result = response.toString();
                    result = result.replaceAll("(\r\n|\n)", "");
    
                } catch (Exception e) {
    
                    Log.e("log_tag_ms", "Error in http connection!!" + e.toString());
    
                }
    
            }
    
    
        return null;
    }
    
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
    
    
        }  }
    

    0 讨论(0)
提交回复
热议问题