简体   繁体   English

将文本数据存储在一个或多个文件中以便可以在各种平台上使用的最佳方法是什么?

[英]What is the best way to store text data in a file/files so it can be used in various platforms?

I'm developing a knowledge base java application, where I can store and retrieve annotations with its title, date when the note was created (SQL datetime), content, tags about the annotation, etc. 我正在开发一个知识库Java应用程序,可以在其中存储和检索带有标题,注释创建日期(SQL日期时间),内容,有关注释的标签等的注释。

It can be done easily with a database (I'm using SQL Server 2014), but the main problem is that the server is running on my own PC and it has to be always on and running the SQL Server. 使用数据库可以轻松完成此操作(我正在使用SQL Server 2014),但是主要问题是服务器正在我自己的PC上运行,并且必须始终在运行SQL Server。 Also, I would like to extend the application by storing and retrieving this kind of data on mobile apps for Android and iOS. 另外,我想通过在Android和iOS移动应用程序上存储和检索此类数据来扩展应用程序。

Is there any other way to store that type of data in some files so it can be uploaded to some cloud storage like Dropbox ? 还有其他方法可以将这种类型的数据存储在某些文件中,以便将其上传到Dropbox等云存储吗? After storing it on Dropbox, all I would have to do is sync the app with dropbox, get the files and read/write stuff. 将其存储在Dropbox之后,我要做的就是将应用程序与Dropbox同步,获取文件并进行读/写操作。

UPDATE: Thanks for all the answers they helped me a lot. 更新:感谢您提供的所有答案,他们对我有很大帮助。 The best solution for me is to replace SQL Server with SQlite, as Gabe Sechan commented. 正如Gabe Sechan所说,对我来说最好的解决方案是用SQlite替换SQL Server。 Now I can make changes on the database without the need of a server running 24/7 and I can use the same database on Android and iOS apps. 现在,无需运行24/7的服务器就可以对数据库进行更改,并且可以在Android和iOS应用程序上使用相同的数据库。

You can use just a basic ajax call to pull content from a Dropbox "public" URL. 您可以仅使用基本的ajax调用从Dropbox的“公共” URL中提取内容。

function(contenturl,intoselector,callback){
            if (contentwindow.currenttopic!==contentID){
                jQuery.ajax({
                    type:'GET',
                    url:'//www.corsproxy.com/'+contenturl,
                    dataType:'text',
                    async:true,
                    success:function(data){
                        intoselector.html(data);
                        if (jQuery.type(callback)==="function")
                            callback();
                    }
                });
            }

Notice that this example pulls through corsproxy so that you don't receive any XSS errors, so the url you pass needs to not contain a protocol itself. 请注意,此示例通过了corsproxy,因此您不会收到任何XSS错误,因此您传递的url本身不必包含协议。

If you want to pull a JSON or XML string that is stored in the file, then you might need to play around with the dataType and contenttype options in the ajax call. 如果要提取存储在文件中的JSON或XML字符串,则可能需要在ajax调用中使用dataType和contenttype选项。

This can also be done using Google spreadsheets: 也可以使用Google电子表格来完成此操作:

Reading: 读:

Writing: 写作:

  • You can use a Google app script for writing to the spreadsheet ( reference ) OR 您可以使用Google应用脚本来写入电子表格( 参考 ),或者
  • You can create a Google form linked to the spreadsheet and simply fill the form from your mobile app whenever you want to add some data to the sheet ( reference ) 您可以创建一个链接到电子表格的Google表单,只要要将数据添加到表单中( 参考 ),只需从移动应用中填写表单即可。

Of all the cloud services, when it comes to Android, Dropbox's Sync API is one of the easiest to implement. 在所有云服务中,就Android而言,Dropbox的Sync API是最容易实现的之一。 Do you need specific code examples on how to sync with Dropbox? 您是否需要有关如何与Dropbox同步的特定代码示例?

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

相关问题 无法使用数据库时存储数据的最佳方法是什么? - What is the best way to store data when a database could not be used? 将结果集数据放入文本文件的最佳方法是什么? - what is the best way to put resultset data into a text file? 在Android应用程序中存储文本数据的最佳方法? - Best way to store text data in an android app? 将操作存储为java中的数据的最佳方法是什么? - What is the best way to store actions as data in java? 在自动化中存储执行期间使用的 sql 查询的最佳方法是什么 - What is the best way to store the sql queries used during execution in Automation 存储常用(不可更改)列表,地图的最佳方法是什么? - What is the best way to store often used (not changeable) List, Map? 从Eclipse导出文件以便可以在多个操作系统上运行的最佳方法是什么? - What is the best way to export a file from Eclipse so that it can be run on multiple Operating Systems? 从HttpSession中存储/检索常用数据的最佳方法 - Best way to store/retrieve frequently used data from the HttpSession 拆分此文本文件的最佳方法是什么? - What's the best way to split this text file? 用Java标记文本文件的最佳方法是什么? - What is the best way to tokenize a text file in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM