Reading bunch of data from a server - android

i have a short question and it would be awesome if someone could give me some directions. I have a listview and an editText field. When I start writing I want fill out the listview with data obtained from some database. Like imagine I have a bunch of addresses somewhere. When I enter "a" I get bunch of addresses that start on a. I know I could use TextWatcher and Filter, I just need to know how to implement the communication between my app and database.
Thanks.

If you are a beginner to making Android backends I would recommend you look into firebase as a backend. It is easy to get started and there is a lot of sample code, especially for listviews. It is less-easy to shoot yourself in the foot so to speak with a backend as a service like Firebase and it is rather popular now.
Best of luck.

I think you can use a cursor adapter to populate the listview. Now to filter the content based on the user input you could use searchview with listview.
Here is a good tutorial :
http://www.coderzheaven.com/2013/06/01/create-searchview-filter-mode-listview-android/

Related

How can I implement the search for a location?

I am planning on making a widget for android. It will basically show pollution data that is gotten from a government data rest endpoint.
My problem is that I want the user to search for and select the location they want data for, much like the weather widget.
I'm thinking that having a persistence database is overkill because the data probably won't ever change and I don't think the location list very big.
Should I put a textfile in the app that is being searched through or is there another more efficient way to approach this problem?
Thanks in advance!

How to get data from server when i enter something in search box like auto search?

i trying to implement auto search mechanism in android like google. Here when i enter some words then display related search results in list view. For example i entered 3 letters then display related search results from server, again i will add another letter to previous 3 letters then automatically display related search results with out click search button.I don't know how to do it, every time api calling. How to use Search view option from android xml for searching?
On client side you should with the help of AutoCompleteTextView, Adapter, HTTPClient and other stuff you handle sending a request to server. On server side you implement Filter after querying database. After filter is done - respond result and via AutoCompleteTextView you show suggestions. Then via Adapter you set list.
Very nice example
Now when you know which way to search better use google. It is rich on that kind of info and if you face some problems - ask new question with exact! problem.
hope it is helpful.

Android ListView Sourced from REST JSON response

I can't seem to find exactly what I'm looking for after a few day's worth of hunting, so if anyone has seen exactly what I'm trying to do elsewhere, I'd love a link or two.
Anyway, I'm trying to build an app to connect into an ERP system that returns user access information in JSON format via REST request using an e-mail address and password. Most users of the system only have a singular access role, so no big deal for them, but others have multiple roles. The trouble I'm having is taking these multiple access roles and adding them into a ListView where they can select the role with which they wish to use to gain access.
Trouble is, I need a display that uses two lines per selection (to properly display all user-pertinent data) and some way to record the user selection. The data useful in the background for the selection would not be displayed, as it would not mean anything to the user. I've been able to take the JSON response and map it to a custom class I designed for it without any problems (not actually all that useful, mostly only helps for discerning the results count prior to displaying multiple results to the ListView). But I can't figure out how to properly build the ListView layout and map the data to the layout. I'm having trouble understanding how to build the view and insert data into new list items.
The best I figure, if I can get the results to display in a ListView and then record the selection in the shared preferences, I'll be golden.
If the listview items being populated from some JSONArray then you could use listview.setOnItemClickListener to get the position of the selected item and match it from the array.Your question seems a little vague. Can you post some code of what you've tried so that it becomes a little clearer?

ContentProvider appropriate for very dynamic data?

I'm an Android newbie, learning the SDK by creating some basic apps. I'm currently working on an app that will display content from a news aggregator with news items and comments on each item. Each news item has an 'id', and many comments associated with it.
Each results page will have a 'before' and 'after' reference id to the news item at the beginning of the page and the end, respectively. So each 'query' will be something like '/?before=$ID' or '/?after=$ID'.
It seems like ContentProviders are the preferred way to store data on android. However, the content of the site changes so much that I question whether or not using a ContentProvider would be wise.
I appreciate any insight.
Well content providers are used by the e-mail app to hold e-mail, gmail to store and sync its mail messages, gtalk and contacts to keep track of the people you know and their chat status, etc.
I am not sure just how dynamic you are thinking, but those are all pretty dynamic.
One way to look at it -- a content provider is just an API to access structured data across processes. If that API serves your purpose, well that's a good sign. The other aspect to them is that usually they are implemented on top of a SQLite database, and that is the easiest way to implement them because there is a lot of framework support for that. So you will most likely be using a SQLite database for your content provider impl. Is a database dynamic enough for you?

How to create message and save it in Android?

i am trying to develop a simple application. i want to create a simple message and want to save it. now, i want to select message from list of messages which i have created and stored.
can any one please suggest me or give an idea for developing the same.
Thanks in Advance
If you substitute the word "message" for "note", you are describing something really similar to the notepad example.
It runs you step by step trough the code you need to make an application that has notes (messages) you can add, and open.
If you are new to Android development you should go trough all the excersises, because it's a really good help, but if you're not you can just download the sollution and use that.
I feel you should go like this:
Have your application store Contacts in a database (I guess you're already doing this)
Have your application store messages in another database (I guess you're already doing this too)
In the UI, display all the messages inside a ListView, by querying them from your message database.
When user clicks on any message, have another screen that loads this message in full, and lets the user select the recipients
Send the text message to the selected recipients now
I just wanted to point out the flow of the app, since the storage and retrieval process os pretty straight forward. I am not sure if this was what you were looking for.
Do let me know.
If you will store little amount of data you can use sharedpreferences
http://developer.android.com/reference/android/content/SharedPreferences.html
If you want a real solution that is sqlite database that comes with android.
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

Categories

Resources