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

  • SEARCH
  • Home
  • 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 9181715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:23:05+00:00 2026-06-17T18:23:05+00:00

I have a question. :) In an app that I am working on, in

  • 0

I have a question. 🙂
In an app that I am working on, in one part I have two tabs, both run by their respective fragment and a listview in each one.
Now, I need to populate those lists with the data I am reading in an SQLite database. I created almost all necessary classes for the DB part, but I am stuck on a part where I need to get this data

 public List<String> getAllRockBands() {
     List<String> bandList = new ArrayList<String>();

     String selection = BAND_GENRE + "=1";
     String orderBy = BAND_NAME+" ASC";

     SQLiteDatabase db = sqLiteHelper.getReadableDatabase();
     Cursor cursor = db.query(BANDDATABASE_TABLE,new String[]{BAND_NAME}, selection,  null, null, null, orderBy);

     int index = cursor.getColumnIndex(BAND_NAME);

     if (cursor.moveToFirst()) {
         do {
          String bandName = cursor.getString(index);
              bandList.add(bandName);
         } while (cursor.moveToNext());
     }

     return bandList;
 }

from my sqlhelper class to my listfragment extended class. The code for it is currently:

public class RockAllFragment extends SherlockListFragment {

private String[] bandList;

 @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
         Bundle savedInstanceState) {

     return inflater.inflate(R.layout.my_list, null);
 }

  @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
 }

 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(getSherlockActivity(),   android.R.layout.simple_list_item_multiple_choice, android.R.id.text1, bandList));
 }
}

Going with private BandDatabaseAdapter mySQLiteAdapter; and using the method through that works only for Activity extended classes and not ListFragment? What would be the best way to acomplish what I want to do? (P.S. I am pretty new to programming for Android, sorry if I made some trivial mistakes 🙂

Thanks,
Aleksa

  • 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-06-17T18:23:07+00:00Added an answer on June 17, 2026 at 6:23 pm

    At the end I found out it was a clumsy starter mistake, just going with mySQLiteAdapter = new DatabaseAdapter(getSherlockActivity()); at onViewCreated and using an array adapter worked just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question. I have an app that use a native DLL through PInvoke, this
This is a real newbie question. I have simple app that selects a picture
A theoretically question: I have a C# Windows Form app, that sends back some
I actually have two questions regarding exception/error handling in the iPhone app that I
SO I'm working on a schedule app that uses a MySQL DB. One of
I am working on one app in which i have implemented the in app
I'm working on an app that, from the Main.mxml, opens one or many Window.mxml
Have only one question How to right dealloc object when app goes to background
I'm working on a web app that's optimized for an iPhone. On one of
I have a question about my app submission to itunes. My app using 256

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.