Say, I have a 100 text files (100kB each) and I'm interested in searching those files for strings/keywords entered by the user.
One way to do this would be to read them every single time and look for the entered string/keywords and I could implement that but it might be inefficient.
Since I know all the data before hand, are there any other better ways to do this?
See example on google devs:
http://developer.android.com/training/search/search.html
They use memory only SQLite database with FTS table. But you could easily change this to persistent db (drop VIRTUAL when creating table).
Press Ctrl+H . It will open search menu. Go to File Search and tick mark the things as per your need and the text which you want to search, write it into the containing text: portion. It will search for your text in the whole project.
Related
I would like to ask if any of you out there uses android studio and sqlite for apps that require multiple users to access the database? I have been looking for source codes and examples online, but haven't seen any. I understand that other database might be better but I only have enough time to use sqlite as I am alr using it now. Could anyone help me with example source codes?
viewComment.setText(name+comment);
replace with below code
viewComment.append("\n"+name+comment);
Update -
limit number comments - use counter , after certain number of hits stop appending to text view.
U can make scrollable too.
for above both please check your requirements or UI/UX teams.
You will have to work with RecyclerView here. Add a different layout resource file in your layout folder and bind it to the RecyclerView and all your comments must be stored somewhere, like in a database. You will then achieve your desired structure.
I am making a framework in order to easily "appify" books.
This framework will need to automatically detect chapter and heading to make a table of contents. The idea is to also be able to easily search through the text and find what you are looking for.
Now what I still need to figure out is:
how to store the data in such a way that I can easily detect the chapters and heading
and still be able to search through the text.
The text that is stored needs to be formatted, so I thought I would store them as HTML or Markdown (which will be translated to HTML). I don't think it would be very searchable if the text is in HTML.
P.S. it does not have to be HTML if there are other more efficient ways to format the text.
Do you really want to do such thing on the device itself?
I can suggest you to use separate sqlite database for every book. With separate tables for table of contents, chapters, summarized keywords of chapters(for faster search) and other service info.
Also here you can find full text search example
Also I recommend you to bring your own sqlite build with your app.
Now lets talk about the main problem of yours - the book scraping.
I have no competency here, I believe this problem is the same as the web sites scraping.
Upd:
Please do not store book contents as HTML, you can store it as markdown for example, it takes less amount of storage, easier to sanitize and you can always apply your styles later
I am working on an app and I basically want to implement some type of function like the note apps do. Basically I have a listview set up that has a link to different xml files. I want the user to have a create new option where they can add some text to an edit text and be able to save the text and add it to the listview I have set up.
My question is how do apps like the Note Pads and Memos ect. do this. Do I need to set up some type of database or?
I have googled it quickly and did a quick search on stack but I don't know if I'm even searching for the right thing. I am just looking for a step in the right direction please!
Thanks!
They all save their data in a database. For android you should use an SQLite database because it is included in the SDK. There are a lot of great tutorials for SQLite out there, but I think that this is the best one
http://www.vogella.com/articles/AndroidSQLite/article.html
It is possible to do this using SharedPrefernces, but I would not recommend it, for efficiency and simplicity
I am trying to use a database for my application which needs a list of all the words in Arabic language, unfortunately this database is very large in size, more than 200 MB, I've seen that the only solution for such a problem is using a web service or having my database online and download it on first use which is not practical in my case since this is a game and the user can play it while he's disconnected, plus the download size will be large and it will use alot of space on his phone. I couldn't find a way to make the size of my DB reasonable.
My question is if there is a way to shrink the size of the database knowing that all the data stored in it is of the type text.
I've noticed that the keyboard in my phone has an auto-complete feature, where is it getting the list of valid words from? Can i use it for my application?
You'll want to store your words in a prefix tree (or trie). It is a space-efficient structure for this kind of data.
For more info, see: https://gamedev.stackexchange.com/questions/4142/best-way-to-store-a-word-list-in-java-android
your database might have so much extra information included, for example grammar, inflections, comments etc. If this is the case, then re-create your database with only the limited data/columns you need to be used inside phone.
What I have is an app that displays some documents. In the string resources I have the documents divided into smaller pieces in anticipation of making them searchable. Think of them like newspapers with a number of articles where each article is a separate string resource. There will not be any storing of user input (unless I decide to store recent searches). In the search part of the android developer docs it mentions this but says it is not going to go into details of how to store and search data just how to use the search dialog and widget.
What kind of storage of my data should I be using. Is simple string resources good? should I look into a real databasing? which of these make it the most efficient and quickest to search? I'm new to android so any help would be appreciated.
answer:using android's built in sqlite database system and FTS3 tables.
I would definitely use a database for this.
Read all the documents and link each word to each document in a database.
A word search would then produce a list of documents containing this word quickly.
Make sure you reindex each time you add and remove a document.
By the way, you should see to improving your accept rate.
Also, this is problably not a Android question.