Android: Custom collation in SQLite - android

Is there a way of getting SQLite on Android to use a custom collation routine?
I'm aware of SQLite's C interface to do this, so I guess I could do it by writing C code for building with the NDK, but I'd really prefer a way to do it at a higher level.
I need to arrange things so that the text B-9 is sorted before B-29, for example. The default alphabetical sort gets them the wrong way round.

I am pretty sure that there is no way to do this in Android.
My suggestion would be to have a custom column used for ordering where you insert the value in a modified way that gets sorted as you wish.
In your case you could insert B-9 as B-09 or B-00....09 depending on the max value.

Related

preference for a list of words

I'm building an Android app whose settings include a blacklist, so the user can input a list of words. I took a look at the TextPreference but it doesn't really fit the scope since it's a dialog with little space.
Is there any preference (built-in or library) I can use for inserting a list of words? A bigger text area with no dialog should be enough. I didn't think that such a simple preference is not available.
Storing a blacklist of words is probably a little out of scope for SharedPreferences, since they are designed to maintain simple key:value pairs.
You should create a new Fragment that allows users to manage the blacklist and then implement your own data persistence. If you use Sqlite and create a clustered index on the column word, you will have O(log(n)) search. Opposed to O(n) search that scanning the csv values of shared preferences would yield.
There are no built-in preferences that provide behavior like that. Also no libraries that i know of.
I recommend creating a custom Preference for this. Internally the preference-v7 layouts setttings screen contains a RecyclerView. So you need to override some sort of ViewHolder logic (PreferenceViewHolder)
This could be usefull: http://www.hidroh.com/2015/11/30/building-custom-preferences-v7/

Can you use a search widget to search for text in android:text="______" fields?

I'm building an app with linear and relative layouts to create lists. I want to have a search function to search through text fields and return the results with "links" to the pages it pulls the results from.
I don't know if I am explaining this well enough, but that's what I need help with. I can find all sorts of search help but it all seems to revert back to ListView's.
You should aim to create your "lists" from some form of data-store. Usually a database, see SQLite Databases in Android. You should then use the query language to return only fields that match your search term e.g. "SELECT * FROM people WHERE name = 'Adam'".
To directly answer your question, the searching of text fields (EditText's or TextViews) is not possible to do automatically and you would need to hard code the search for each individual one.

Android User Interface like NumberPicker but data from SQLIte

How could I make a user Interface like the one with NumberPicker but the data came from the SQLite. Is there a Layout for this?
Like this User Interface
What do they call this Interface?
I'd like to create a view data from SQLite. Some what like
Apple
Banana
*Cake*
Donut
Eclair
Don't recommend using DialogFragment. I wanna do like this
Scrollable List
Unfortunately there is no layout that does that out of the box, so you will have to do a lot of heavy lifting before getting things working. But the easiest way is to use NumberPicker and pass to it the values that you want to display as an array with setDisplayedValues. But you still have to create the connection to the database and query for the cursor that you will have to transform somehow to an ordered array, for which you can then map the values of the NumberPicker to the actual values in the database (told you, not easy...).
There is no easy way out of this, you could also try making your own component or buy one that does this for you.
This is what I've been looking for.
https://play.google.com/store/apps/details?id=antistatic.spinnerwheel.demo
Source code: https://github.com/ai212983/android-spinnerwheel

Implementing AutoCompleteTextView/SearchView with autosuggestions over large dataset

I would like to ask if my concept of implementing search in my application is correct and whether it could be improved. I will provide any details needed therefore I believe my question is well-suited for this site.
I need to implement a search over large SQLite tables (~20 columns,
possibly 1000-1500 records - you can think of it as a catalogue of
items in a supermarket). The search should be performed on more than
1 table (i.e. 1 catalogue) but I can also force the user to choose
specific table (though I would like to avoid it).
To make the search efficient, I'll use the SQLite FTS3 tables.
I want to make a fast search that will quickly show results as the user types a query string. For example, when a fragment of
product manfufacturer is entered all of the products matching that
string should be shown. The perfect solution would be if the user
could enter fragment of one column and fragment of another at the
same time, though I think that could be a little too much for an
Android device.
Questions:
Should I use a SearchView together with a a ListView (and show search results in the ListView) or should I use the AutoCompleteTextView?
Are the FTS3 tables the right way to go (i.e. will it be fast enough) to effectively perform search over several (large) tables?
I am targeting Android versions >= 3.0.
If you want to have a few line of code, you should use AutoCompleteTextView for it has ready built-in listener (ontextChangelistener -- wherein you can show the suggestions every time the text changes ) and list/ container for suggestions.You can create your own adapter to customize the design of the list.
FTS3 or FTS4 would be great in querying big amount of data.

Customized Listview with Numberpicker in android 4.0

I need to develop a task with the concept of Providing points to the Competitors. It must be done Dynamically. So i have chosen the NumberPicker for the Points value. I need to list the Competitors from the Database and it will be in two separate columns such as Id and Name.
While the run time i need to Evaluate and Put Points to them by using NumberPicker with a range of 0-10.
And i need to Get the value from the NumberPicker to the Textview and store the Value in my Database
Please Help me for my Task..
Thanks In Advance

Categories

Resources