带有离线数据库的android词典应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12369879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:28:40  来源:igfitidea点击:

android dictionary application with offline database

androidsqlitedatabase

提问by Dunkey

I want to develop an android English dictionary application that uses only an offline database. By that, I mean to say that it doesn't have to be redirected to online dictionary like WordWeb or the like. Does anybody know what should I do to store my words? I'm thinking of using SQLite since it's mobile. But if anyone here already has done or did something what I want to do, can you give me some expert suggestions?

我想开发一个仅使用离线数据库的 android 英语词典应用程序。我的意思是说它不必被重定向到像 WordWeb 之类的在线词典。有人知道我应该怎么做来存储我的话吗?我正在考虑使用 SQLite,因为它是移动的。但是如果这里有人已经做了或做了我想做的事情,你能给我一些专家建议吗?

采纳答案by Syamantak Basu

http://developer.android.com/resources/samples/SearchableDictionary/src/com/example/android/searchabledict/DictionaryDatabase.html

http://developer.android.com/resources/samples/SearchableDictionary/src/com/example/android/searchabledict/DictionaryDatabase.html

I have used this code from developer.android.com . Hope it will help you also.

我使用了 developer.android.com 中的这段代码。希望它也能帮助你。

EDIT: This page is no longer available, but the example itself is on Github here.

编辑:此页面不再可用,但示例本身在 Github 上

回答by Walid Fouad

I already did this to my dictionaries:

我已经对我的字典这样做了:

https://play.google.com/store/apps/developer?id=e-Biene%20DEV&hl=en

https://play.google.com/store/apps/developer?id=e-Biene%20DEV&hl=en

You can make conversion to your simple database, tblLanguage1[word, translation] tblLanguage2[word, translation]

您可以转换为您的简单数据库, tblLanguage1[word, translation] tblLanguage2[word, translation]

to (SQLite format [extract it from emulator], and then attach this converted SQLite db with your App offline).

到(SQLite 格式 [从模拟器中提取],然后将此转换后的 SQLite db 附加到您的离线应用程序中)。

It will be quick and fast for searching.

搜索将很快。

and Use: DB created in emulator with structure like: Tables:

并使用:在模拟器中创建的数据库,其结构如下:表:

lang1_Content lang1_segments lang1_segdir

lang1_Content lang1_segments lang1_segdir

use this instead of simple.

使用它而不是简单的。

回答by Zsombor Erd?dy-Nagy

I'd go with using SQLite, that's probably the easiest and most straightforward way to do it on Android. Of course the complexity of this solution depends on you exact needs. If you only need a really simple dictionary, then you could get away with a simple db schema with basic queries.

我会使用 SQLite,这可能是在 Android 上最简单、最直接的方法。当然,此解决方案的复杂性取决于您的确切需求。如果您只需要一个非常简单的字典,那么您可以使用带有基本查询的简单 db 模式。

Another thing that comes to mind is the Trie data structure, you may want to look into that: http://en.wikipedia.org/wiki/Trie#Dictionary_representation. But it probably wouldn't worth the hassle to pull this off using this, I'd guess that the performance of the SQLite solution is more than enough for your needs.

想到的另一件事是 Trie 数据结构,您可能需要研究一下:http: //en.wikipedia.org/wiki/Trie#Dictionary_representation。但是使用它来解决这个问题可能不值得,我猜想 SQLite 解决方案的性能足以满足您的需求。

回答by Ray Foss

Try the Google API samples, I know they have a Dictionary application. I'm pretty sure it's offline too. I had to build something with an offline cache, I used JAVA's excellent XML parser to load things into the SQLite database. When the user had an internet connection, it would download a new XML and use that to update the database. You can store any type of file with your application however.

试试 Google API 示例,我知道他们有一个 Dictionary 应用程序。我很确定它也是离线的。我必须使用离线缓存构建一些东西,我使用 JAVA 出色的 XML 解析器将东西加载到 SQLite 数据库中。当用户有互联网连接时,它会下载一个新的 XML 并使用它来更新数据库。但是,您可以在应用程序中存储任何类型的文件。

http://developer.android.com/tools/samples/index.htmlThe sample I'm talking about is called Searchable Dictionary.

http://developer.android.com/tools/samples/index.html我正在谈论的示例称为可搜索字典。

回答by teoREtik

Your primary problem is to specify what essential will store your dictionary.

您的主要问题是指定存储字典的基本内容。

There are a lot of ways provided by Android to store your data such like:

Android 提供了很多方法来存储您的数据,例如:

  • SharedPreferences
  • 共享首选项
  • File saved in device's internal storageor external storage
  • 文件保存在设备的内部存储器外部存储器中
  • SQLite database
  • SQLite 数据库
  • You also may create a static database and store it in your assetsfolder as described in thispost.

    您还可以创建一个静态数据库,并将其存储在您assets的描述文件夹这个职位。

    Also you may check for Searchable Dictionary from android-sampleswhich is a good example of implementing a search for your app and also there described some technics of storing data.

    您也可以检查 Searchable Dictionary 从中android-samples是实现应用程序搜索的一个很好的例子,并且还描述了一些存储数据的技术。

    回答by Ujjwal Kumar Gupta

    The best approach is that - keep your data in files say in json file and keep it on the web or you can also uplaod this on googledrive or dropbox and make it public and after that when user will open the app for first time, download the json files and insert the data from json into sql lite db.This way you can use sql lite for offline data.

    最好的方法是 - 将您的数据保存在 json 文件中的文件中并将其保存在网络上,或者您也可以将其上传到 googledrive 或 dropbox 并将其公开,然后当用户第一次打开应用程序时,下载json 文件并将 json 中的数据插入 sql lite db。这样您就可以将 sql lite 用于离线数据。