【问题标题】:how to store data and retrieve it using network connection in android如何在android中使用网络连接存储和检索数据
【发布时间】:2016-07-13 07:47:35
【问题描述】:

对不起,如果这个问题听起来很愚蠢。我是 android 新手,我正在研究 android 中的数据存储选项。我的问题是如何将数据存储在云或服务器上并在需要时检索它。

如果可能的话。我想学习和实践它。有没有什么选择可以练习,比如免费的云空间或服务器空间,我可以在上面存储我的数据并检索它以进行练习。

数据可以是图像、文本、结构化数据等

请指导我。我已经完成了主题 sharedPreference、InternalStorage、ExternalStorage 和 Sqlite。现在正在寻找在云或服务器上存储数据

【问题讨论】:

标签: android storage android-networking android-database


【解决方案1】:
Url url=new Url("server address");
HttpURLConnection httpURLConnection =(HttpURLConnection)url.openConnection();
        httpURLConnection.setConnectTimeout(3000);   
        httpURLConnection.setDoInput(true); 
        httpURLConnection.setDoOutput(true);  
        httpURLConnection.setRequestMethod("POST");      
        httpURLConnection.setUseCaches(false);               

        OutputStream outputStream = httpURLConnection.getOutputStream();
        outputStream.write(data);

【讨论】:

    【解决方案2】:

    例如,您可以使用 Google 云端硬盘进行练习。有 Google Drive API。上传一些文件并在您的应用程序中实现 API 模块。 有一个非常好的 android 库,可以让你编写非常好的 API 模块。检查this

    【讨论】:

      【解决方案3】:

      检查火力基地。您可以通过在 android studio 中选择一个选项来进行设置。这是最好的开始。

      【讨论】:

        【解决方案4】:

        如果你想在服务器上存储数据,那么你需要后端编程来连接安卓。你可以更喜欢这个教程。http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-08-10
          • 2013-09-04
          • 1970-01-01
          • 2017-11-15
          • 1970-01-01
          相关资源
          最近更新 更多