如何返回[查询]结果作为文件的位置? [英] How to return [search] result as file location?
问题描述
我正在搜寻能够解释。它使用SQLite数据库。字典格式是如下图所示(2列由 - 隔开)
I'm working on Search able Dictionary. It uses SQLite database. Dictionary formats are like below (2 column separated by "-")
Apple - One kind of fruit
Cricket - One type of game
Titanic - One type of Movie
下面苹果
是列 A
和一类的水果
是列 B
我已经更新了我的数据库像下面
I've updated my database like below
Apple - res/raw/Apple.txt
Titanic- res/raw/Titanic.txt
我想开 Apple.txt
文件并显示文本时,用户搜索苹果
。但样本code我使用的是TextView的制作而已,不打开文件,缓冲区和ViewText。
I want to open Apple.txt
file and show text when user search Apple
. But the sample code i'm using is made for TextView only, not to open file, buffer and ViewText.
下面是我的code这显示了我的应用程序列B
Here is my code which shows Column B on my application
TextView details = (TextView) findViewById(R.id.details);
details.setMovementMethod(new ScrollingMovementMethod());
请建议我怎么能打开Apple.txt从搜索查询替换上述code?
Please suggest how can i open Apple.txt from search query by replacing above code?
[更新后]
推荐答案
您可以根据使用拆分 -
:
String[] res = line.split("\\s+-\\s+");
现在你必须是这样的:
[Apple, One kind of fruit]
现在,因为你在A列中有苹果
,你知道你必须展示 apple.txt $ C $的位置C>。
Now, because you have Apple
in column A, you know that you have to show the location of apple.txt
.
或者(更好的方法),可以存放在B列的路径@Egor在评论中指出:
Alternatively (a better approach), you can store the path in column B as @Egor stated in the comments:
Apple - the_path_to_open.txt
而现在,当你拆,你会得到的路径中的 1 数组(这是列B)的元素,你可以打开它,以显示其结果。
And now, when you split, you'll get the path in the 1 element of the array (Which is column B) and you can open it to show its' results.
这篇关于如何返回[查询]结果作为文件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!