Displaying data from DB in a table. Android - android

I am looking for a simple way to display data from DB on the phone screen. Best I would like to create a table (not DB table, but table on the screen) which would display all the data I want. Is there any easy way to do it? The only idea I have is by using custom listView, but I'm not sure it will work as I want it to. I don't want to be able to interact with a table, just to be able to display the data.

Use a CursorAdapter to bind the queried Cursor to your ListView. Make sure you query for the Cursor on a background thread with a CursorLoader for the most responsive user experience.

Related

Add a class/table inside another one in Parse.com (android)

In one of my Parse.com classes/tables I'd like to have a column where another class/table can be stored for each row. As an example:
An User table with a Clothes row, in which a table with the name and color of each of the user's items can be stored.
I've done this using relations but was wondering if there's a way to do it without having to create another table and making a relation to it, since that creates two tables (the table itself and the relation). I'm just trying to make it so Parse.com has the least stress so querys or any method can be done in the least time.
Thanks, if I didn't make myself clear please ask.

Displaying data via table format (Android)

I have 2 columns of data in my database in Android application. I want to display this data via a table format in my application. Please help me.
For example, I have employeename and department coulmns in the database. I want to retrieve this data and show it in a table format like a table with 2 columns. One side employeename and next column their respective department in my Android application.
Unless you want user interact with the table, you can use webview and make it load table html. Advantage of this method is that you can make it as fancy as you want.
If you want interaction with the table, you'd better use listview with customized row layout, or even gridview would work too.

Table data showing

I am building one app which is a copy of a website.
In that website they showed some bulk of data in a table view (with multiple rows and columns)
I want to show the same bulk of data in android mobile.
But the problem is which widget will be reliable to show large amount of data (like table). And which widget will give efficient and professional look.
Please suggest some widget or views
For a static (predefined/known)
content you can use TableLayout,
as in this example,
For dynamically populate the table
you should use a GridView
(considering as an option the
ListView as well: if you don't
have many columns, an proper item
renderer would be more efficient).

Android spinner from sqlite - best method?

So at the moment I have a simple reminder app that you enter some details, select a data and time and then the app reminds you on the selected date/time.
I now want to be able to add functionality to select categories which I want to select from a spinner, which is populated from separate database table - I will be adding a class to add new categories.
Is an sqlite database the best way of doing this or is there an easier alternative? I assume I will need to make foreign keys/triggers?
Any advice is much appreciated.
Yes, I think the best way is to use sqlite3, especially if you're mutating data.
Spinner is an AdapterView like ListView or GridView, so you can just use a CursorAdapter (or possibly SimpleCursorAdapter) to populate it with data from your database.
This looks like a decent tutorial for creating a SimpleCursorAdapter. In your own code you would call spinner.setAdapter(mySimpleCursorAdapter);

listview adapter implementation

With the application i am working on i came with the following problem. I have a listview that should display data from a data base table. There are two scenarios that could happen:
Scenario one - the database table is filling dynamically and the listview also should dynamically display table's information e.g to grow depending on table size.
Scenario two - the table has been already filled and the listview has to just display the content
So the problem is how to accomplish this behavior using ListView and ListAdapter.
So far i have solution for each scenario but no for the two together.
Scenario one - Use AsyncTask and ArrayAdapter. In doInBackGround query the db periodically and pass the result to onProgressUpdate, than just fill the ArrayAdapter with the newly added values. But when came scenario two i query all the table than copy all values to the ArrayAdapter in one step which is pretty slow.
Scenario two - Query the db again the just use CursorAdapter. But in this case i can't update the ListView dynamically using CursorAdapter.
So any ideas how to implement this using one adapter, or just should i use ArrayAdapter and CursorAdapter depending on the case ?
Scenario one - the database table is
filling dynamically and the listview
also should dynamically display
table's information e.g to grow
depending on table size.
Try:
Scenario 1a: Whoever is getting the data not only puts it in the database, but tells the activity "here's some new data to display".
Databases are great data stores but are lousy pipes. Your "Scenario one" tries to use the database as a pipe -- instead, pipe around it.
Now, if the case is that you have both in-the-database data and new data coming in, you'll need to stitch those datasets together. You can use my MergeAdapter for it: give it two ListAdapters, one representing your existing data (perhaps a CursorAdapter) and one representing the new data (perhaps an ArrayAdapter). It will render them as a combined entity.

Categories

Resources