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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:50:06+00:00 2026-05-26T08:50:06+00:00

I have jokes.db database. This database file imported from using this article., http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/ .

  • 0

I have jokes.db database. This database file imported from using this article., http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/. Now i have Jokes.db in to /data/data/a.b.c/database/Jokes.db. In this database , I have two table NepaliJokes and EnglishJokes. So Now I want to retrive this nepali and english jokes and display in to textview, But I have done following code but couldnot more idea behind How to retrieve data from database.

public class FunnyJokes extends Activity implements View.OnClickListener {
private SQLiteDatabase database;

@Override
protected void onCreate(Bundle savedInstanceState) {
    Button back;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.displayjoks1);

    back = (Button) findViewById(R.id.back_btn);
    back.setOnClickListener(this);

    DataBaseHelper helper = new DataBaseHelper(this);
    database = helper.getWritableDatabase();
    loadJokes();
}

private void loadJokes() {
     //jok=new ArrayList<String>();
      /*Cursor c = database.query("SELECT title,body" +
                                             " FROM " + 'tableName'
                                             + " WHERE category=1;",
                                             null);*/
     Cursor c = database.query("NepaliJokes", 
                null, null, null, null, null, null);

 c.moveToPosition(0);
 TextView tv= (TextView) findViewById(R.id.textView1);
 tv.append(c.getString(1));
 c.close();
}

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.back_btn:
        FunnyJokes.this.finish();
        break;

    default:
        break;
    }

}
}

I also use the database file import from in DDMS->fileExploer. I import database file Pull mobile icon from left of file explorer section.

  • 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-26T08:50:07+00:00Added an answer on May 26, 2026 at 8:50 am

    To read values from the table:

    1. Create a cursor to read data from the database.

      Write the following function.

      public Cursor retrieveRecords(int category)
      {
        Cursor c = null;
        c = db.rawQuery("select title,body from tablename where category=" +category, null);
       return c;
      }
      
    2. Now get the values from the cursor.

      public void getDataFromDatabase()
      {
          try
          {
              Cursor cursor = null;
              db.OpenDatabase();
              cursor = db.retrieveRecords();
              if (cursor.getCount() != 0)
              {
                  if (cursor.moveToFirst())
                  {
                      do
                      {
                          titleArrayList.add(cursor.getString(cursor.getColumnIndex("title")));
                          bodyArrayList.add(cursor.getString(cursor.getColumnIndex("body")));
                      } while (cursor.moveToNext());
                  }
                  db.closeDatabase();
              }
              cursor.close();
          }
          catch(Exception e)
          {
              e.printStackTrace();
          }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site logs clicks to a database whenever a user views an article. This
Let's say I have a shape like this: After all the jokes of me
I'm new to LINQ and C# but I have an xml file generated from
I have created database by using SQLite Database browser . I have to follow
I have some simple code which should create a database. package com.webfoo.android.databaseExample; import android.app.Activity;
Alright so I have the query (SELECT * FROM jokes WHERE flags < 5
I have a string of names like this J. Smith; B. Jones; O. Henry
Have just started using Google Chrome , and noticed in parts of our site,
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.