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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:11:51+00:00 2026-06-07T00:11:51+00:00

My application has multiple SQLite tables(around 20 with different fields). This I have created

  • 0

My application has multiple SQLite tables(around 20 with different fields). This I have created it using Adapter class(Here i have just mentioned one class Game, Like that i have 20).

public class MyDbAdapter {
private SQLiteDatabase mDb;
private static MyDatabaseManager mDbManager;
Context ctx;

public MyDbAdapter(Context context) {
       this.ctx =   context;
    mDbManager = new MyDatabaseManager(context);
    mDb = mDbManager.getWritableDatabase();
}

public static final class GameColumns implements BaseColumns {
    public static final String TABLE = "game";
    public static final String IMEI = "imei";
    public static final String LAST_UPDATE = "lastupdate";
    public static final String NICKNAME = "nickname";
}



private static class MyDatabaseManager extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "dbname";
    private static final int DATABASE_VERSION = 8;

    private MyDatabaseManager(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        createGameTable(db);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

       db.execSQL("DROP TABLE IF EXISTS "+GameColumns.TABLE);
        onCreate(db);

    }

    @SuppressWarnings("unused")
    private void dropDatabase(SQLiteDatabase db) {
        db.execSQL("DROP TABLE IF EXISTS " + GameColumns.TABLE);
    }

    private void createGameTable(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE " + GameColumns.TABLE + " ("
                + GameColumns._ID + " INTEGER PRIMARY KEY,"
                + GameColumns.IMEI + " TEXT,"
                + GameColumns.LAST_UPDATE + " TEXT,"
                + GameColumns.NICKNAME + " TEXT);");

      }
  }
 }

Data From each table is fetching using below code. This function returns Cursor object.

public Cursor getRecords(String tableName){
    Cursor cursor   = mDb.query(tableName, null, null, null, null, null, null);
    return  cursor;
}

I need to convert Cursor Object to either list or string. For this we need to iterate the cursor Object. My problem is, each table has different fields, So i need to iterate each cursor object in separate method. How can this be done using single method?
Is there any direct way to convert cursor to string?

  • 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-07T00:11:52+00:00Added an answer on June 7, 2026 at 12:11 am

    you can use HashMap like…

    ArrayList<HashMap<String, String>> items = new ArrayList<HashMap<String, String>>();
    
    int col_count = cursor.getColumnCount();
                        while (cursor.moveToNext()) {
                            HashMap<String, String> currentItem = new HashMap<String, String>();
                            for (int i = 0; i < col_count; i++)
    
                            {
                                String col_name = cursor.getColumnName(i);
                                currentItem.put(col_name, cursor.getString(i));
                            }
                            items.add(currentItem);
                        }
                        cursor.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has multiple releases for different clients. For each client
I have a web application with multiple web services. This web application has business
In an application that has multiple webviews, is there any way to have the
Hi Sitepoint wizard people, Say we have an admin application that has multiple users
I have a Flex3 application which has to be capable of uploading multiple files
We have an application that has a primary window, it can launch multiple other
I have an application with multiple forms, each form has the same icon, so
Problem : I have multiple instances of the same C# application running on different
Suppose application has multiple apks for different countries. If US user with international roaming
I have an application that has multiple threads processing work from a todo queue.

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.