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 8473653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:24:38+00:00 2026-06-10T17:24:38+00:00

this might be a long message but i would like to give a clear

  • 0

this might be a long message but i would like to give a clear question for all of stackoverflow user.
What I did is create a static String of array inside a class that is binded on my gridview

class ParserArrayList {
       //some declaration and codes here
      private String [] imageCaptionId = {
        "My First Medal",
        "You ...",
        "The ...",
        "Gimme ...",
        "A ...",
        "Seven ...",
        ".....City",
        ".... Madness",
        "Loyal...",
        ".....",
        "...",
        "Champion..."
        };
}

And manually binding it on public class ImageAdapter extends BaseAdapter

public class ImageAdapter extends BaseAdapter{
//some declaration and variables here
   public View getView(int position, View convertView, ViewGroup parent) {
        View v;

        ParserArrayList arrayImage = new ParserArrayList();
        String[] imagetext = arrayImage.getImageCaptionId(); 
        if (convertView == null) {
        //some stuff here
        }
//some stuff here
return v;
}

As you see I am calling ParserArrayList’s ‘imageCaptionId’ and sends it to another string of array in which i declare ‘imagetext ‘

Everything works fine until I found out that the array ‘imageCaptionId’ must be based on local database
Ive tried using this code but I cant finish because

class ParserArrayList {
//added this code
public SQLiteAdapter sqlAdapter;
//and this one
public void showData(){
    sqlAdapter = new SQLiteAdapter(this);

    String str = "Select dTitle from achievement_tb where version =0 order by ID ASC;";

    sqlAdapter.openToRead();

    Cursor c =sqlAdapter.read(str);

    sqlAdapter.close();
}
}

First: I dont know how to bind it to array

Second: I created it inside ParserArrayList and it gives me an error saying
The constructor SQLiteAdapter(ParserArrayList) is undefined (This is already done)

Could you help me sir

EDIT
This is what I am trying to accomplish or my logic

on my ParserArrayList class I am trying to add this code (I dont know if this is correct)

    public String[] showImageCaption(){
    String imageCaptionIds [];
    sqlAdapter = new SQLiteAdapter(mContext);

    String str = "Select dTitle from achievement_tb where version =0 order by ID ASC;";

    sqlAdapter.openToRead();

    Cursor c =sqlAdapter.read(str);     
    imageCaptionIds [c.getCount()];

    sqlAdapter.close();
    return imageCaptionIds;
}

which gives me an error saying Syntax error, insert “AssignmentOperator Expression” to complete Expression

now on my ImageAdapter extends BaseAdapter here is my codes

 public View getView(int position, View convertView, ViewGroup parent) {
        View v;
        ParserArrayList arrayImage = new ParserArrayList(mContext);
        newArrayList2 = arrayImage.getArraylist();
        **String[] imagetext = arrayImage.showImageCaption();** 
        if (convertView == null) {  // if it's not recycled, initialize some attributes
             LayoutInflater li = getLayoutInflater();
             v = li.inflate(R.layout.medal_grid, null);
        }
        else
        {
             v = convertView;
        }
        TextView tv = (TextView)
        v.findViewById(R.id.grid_item_label);
        **tv.setText(imagetext[position]);**
        ImageView iv = (ImageView)v.findViewById(R.id.grid_item_image);
        iv.setImageResource((Integer) newArrayList2.get(position));
        return v;
    }

My logic is that I will bind it on my array of String inside ParserArrayList (in which it will return imageCaptionIds) and set it on a textview

  • 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-10T17:24:40+00:00Added an answer on June 10, 2026 at 5:24 pm

    I don’t understand the first question, but the second one is easy.

    You need to pass a Context (or a class that extends Context, like an Activity) to new SQLiteAdapter(). Simply change your ParserArrayList to match this:

    public class ParserArrayList {
        Context mContext;
        ...
    
        public ParserArrayList(Context context) { 
            mContext = context;
            ... 
        }
    
        public void showData(){
            sqlAdapter = new SQLiteAdapter(mContext);
            ...
        }
    }
    

    Inside your Activity, perhaps onCreate(), simply call:

     ParserArrayList pal = new ParserArrayList(this);
    

    I’ll attempt to answer the first question. Why must your String array be put into a SQLiteDatabase? An ArrayAdapter<String> works quite well with String arrays… Why won’t something like this work?

    public class ImageAdapter extends ArrayAdapter<String> {
        //some declaration and variables here
    
        public View getView(int position, View convertView, ViewGroup parent) {
            View v;
    
            String imagetext = getItem(position); // returns the caption at index
            if (convertView == null) {
                //some stuff here
            }
    
            //some stuff here
            return v;
        }
    }
    

    With a declaration:

    private String [] imageCaptionId = { ... };
    ImageAdapter adapter = new ImageAdapter(this, R.layout.awesome, imageCaptionId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, This might seem like a long question. I don't think it is... The
It might be a long shot posting this question here but we will see.
This might seem like a very easy question for some of you folks, but
This might sound like a stupid question but just trying to learn something here.
I know this might be a long shot, but here it goes. I have
:) This might look to be a very long question to you I understand,
This might be a simple question but I've searched and searched and can't find
This might be a very basic question but it confuses me. Can two different
This sounds like a relatively simple question, but I haven't been able to get
This maybe not possible but I thought I might just give it a try.

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.