简体   繁体   English

使用Sync API Android将文件上传到保管箱

[英]upload file to dropbox using Sync API android

I am trying to develop a simple android application using the Sync API for dropbox. 我正在尝试使用适用于Dropbox的Sync API开发一个简单的android应用程序。 The user clicks a scan button which launches a QR Code scanner. 用户单击扫描按钮以启动QR码扫描仪。 The QR code that is read is the file name for a file on dropbox. 读取的QR码是Dropbox上文件的文件名。 Eg qr code reads 123456.txt 例如,二维码读取123456.txt

The txt files are a list of 14 items set out with one item per line eg. txt文件是14个项目的列表,每行列出一个项目,例如。 ITEM 1 ITEM 2 ITEM 3 项目1项目2项目3

The file is read into an ArrayList,I can download and read the file no problem, but the problem is changing the file on dropbox when the user clicks save. 该文件被读取到ArrayList中,我可以下载和读取该文件没有问题,但是问题是用户单击保存时在保管箱上更改了文件。 Each item is loaded into an EditText and when save is pressed it reads all of the edittexts and replaces the original file. 每个项目都加载到一个EditText中,然后按Save读取所有Edittext并替换原始文件。 I've tried a simple 我尝试了一个简单的

testFile.writestring(array.getItem(0).toString();
testFile.writestring(array.getItem(1).toString();
etc

But I get one file being replaced x many times for each string. 但我得到一个文件,每个字符串被替换了很多次。 For example for those two lines I get one file with just 'ITEM 1' as the contents then a few seconds later it gets updated to just 'ITEM 2' 例如,对于这两行,我得到一个仅包含“ ITEM 1”作为内容的文件,然后在几秒钟后将其更新为仅“ ITEM 2”

Any Ideas? 有任何想法吗?

If I understand correctly what you're trying to do, I think you want something like this: 如果我正确理解您要执行的操作,则认为您需要这样的内容:

testFile.writeString("\\n", TextUtils.join(array));

(Apologies if the syntax isn't quite right. I've never done any Android development, and TextUtils.join is specific to that platform.) (如果语法不太正确,则表示歉意。我从未做过任何Android开发,而TextUtils.join专门针对该平台。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM