Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:30:41+00:00 2026-05-26T16:30:41+00:00

I’m making a new Android app that essentially mirrors data available on our website.

  • 0

I’m making a new Android app that essentially mirrors data available on our website. The GUI will show either a ListView with images and text in each item, or a RelativeLayout that will display details of a single item.

In order to increase responsiveness in this app, I’d like to read data from the internal DB if the data is recent enough, and read data from the server’s API (JSON over http) if the internal data is too old (and then populate the internal DB with the new data).

From the basic tutorials, it seems that one should use the DB and SimpleCursorAdapter (*) when reading from the internal DB. But when reading from the web, I guess I’d be using an ArrayList and ArrayAdapter.

Is there some type of Adapter that can handle both situations?

(*) I know the latest thing is to use LoaderManager with a CursorLoader, but I’m trying to support Android 2.1. I figure I can put the SimpleCursorAdapter into an AsyncTask and avoid ANR.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:30:41+00:00Added an answer on May 26, 2026 at 4:30 pm

    I think you can write a custom Adapter, extending BaseAdapter class and use it for both cases.

    In your class, that extends BaseAdapter, you will have a List<DataEntry>, where DataEntry is Java POJO class, representing the data coming from web or db (assuming it has the same properties). Assuming you have populated the List<DataEntry> with DataEntry objects, already containing data you can do as follows:

    1) In the getView() method of the class that extends BaseAdapter, in the inflate, you will use an xml layout, that’s basically represents 1 data row. Assuming you will display data via TextView, the 1 data row layout will have as many TextView elemnts, as the number of data-fields of your DataEntry object. After the inflate, you put values in the TextViews like:

        TextView someTextViewToDisplayField = (TextView) convertView.findViewById(R.id.yourID);
        someTextViewToDisplayField.setText(String.valueOf(dataEntry.getWhateverProperty()));
    

    2) in the process where you update the UI in your layout you should have a ListView like:

        <ListView android:id="@+id/YourListViewID" android:layout_width="fill_parent"
        android:layout_height="wrap_content"></ListView>
    

    and after that you initialize your class that extends BaseAdapter

       ListView listView = (ListView) findViewById(R.id.YourListViewID); 
    
       YourClassExtendingBaseAdapter adapter = 
                new YourClassExtendingBaseAdapter(this, listOfEntryDataObjects);
    
        listView.setAdapter(adapter);   
    

    the listOfEntryDataObjects is List<DataEntry> already populated with data. The ‘this’ in the constructor is the context associated with the current Activity, you make the call from.

    Structure of class that extends BaseAdapter:

    public class YourClassExtendingBaseAdapter extends BaseAdapter { 
    
        private Context context;
        private List<DataEntry> entries;
    
    public YourClassExtendingBaseAdapter(Context context,
            List<DataEntry> entries) {
        this.context = context;
        this.entries = entries;
    }
      // Overwriting necessary methods 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.