Android登录并下载csv文件

发布于 2024-09-30 07:07:08 字数 728 浏览 0 评论 0 原文

我正在编写一个 Android 应用程序,我需要下载一个图表的 csv 文件。我不确定是否需要将两列放入两个数组字符串或将它们导入数据库然后进行查询。我倾向于将它们放入字符串中,因为 csv 文件会不断变化。

我的两个问题是:

  1. 我需要登录特定 URL 以使用正确的数据填充 CSV,例如 http://myurl.net/protect/module_graph.htm?log=02。这将使用数据填充文件 http://myurl.net/protect/data1.csv以获得正确的项目。将 log=02 更改为 log=03 或任何其他数字都会更改 data1.csv 文件的内容。当我在网络浏览器中提取第一个 URL 时,它会弹出一个窗口,要求进行基本身份验证。我需要如何调用 URL 来发送请求中的用户名和密码?

  2. 我需要下载 CSV 文件并将两列输出为字符串,以便图形代码可以从字符串中读取数据。我想我知道如何下载它,但我应该将其存储到 SD 卡然后输出数据还是只是从网络打开文件然后输出数据?另外,如何告诉它将每一列放入数组字符串中?

任何帮助表示赞赏。非常感谢代码示例或教程或其他选项的链接:)

谢谢!

I am writing an Android app and I need to download a csv file for a graph. I am not sure if I need to either put the two columns to two array strings or import them to the DB then just query. I am leaning towards just putting them to strings since the csv file will change constantly.

My two issues are:

  1. I need to log into a specific URL to populate the CSV with the correct data such as http://myurl.net/protect/module_graph.htm?log=02. That will populate the file http://myurl.net/protect/data1.csv with the data for the correct item. Changing the log=02 to log=03 or any other number changes the content of the data1.csv file. When I pull up the first URL in a web browser it pops up a window asking for basic authentication. How do I need to call the URL to send the username and password with the request?

  2. I need to get the CSV file downloaded and have the two columns output as strings so the graphing code can just read the data from the strings. I think I know how to download it but should I store it to the SD card and then output the data or just open the file from the web and then output the data? Also how do you tell it to put each column to an arraystring?

Any help is appreciated. Code examples or links to tutorials or other options are much much appreciated :)

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2024-10-07 07:07:08

你从来没有说过,但我假设你正在开发一个Android应用程序:

  1. Use HttpClient GET with 身份验证:一个 示例

  2. 再次使用 HttpClient GET 和 查看回复

You never say it, but I assume you are developing an Android app:

  1. Use HttpClient GET with authentication: an example.

  2. Again use HttpClient GET and look at the reply.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文