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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:56:04+00:00 2026-06-06T23:56:04+00:00

Possible Duplicate: Create SQLite DB in Android library I am making a Java library

  • 0

Possible Duplicate:
Create SQLite DB in Android library

I am making a Java library and I need an SQLite database to be opened or created at runtime for my library to store data etc…

All the SQLite API for Android I’ve seen requires a context, from an activity to create a DB,since I’m doing a library, without activity etc… how can I get an SQLite DB ?

The problem is my library has only one public class, and inside my library in my inner workings I need to create a SQLite DB for private use.
So I can’t just ask the user to send in a context. Or can I ?

Just see for how does Google do it in their library ?
At no point when I’m using the analytics library for Android do I pass anything other then an app id for analytics. And In their documentation you can read: “Pageviews, events and Ecommerce hits are stored in an SQLite database and dispatched to the Google Analytics servers periodically

  • 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-06T23:56:05+00:00Added an answer on June 6, 2026 at 11:56 pm

    how can I get an SQLite DB ?

    Have the consumer of your library supply you with a Context.

    So I can’t just ask the user to send in a context. Or can I ?

    Yes, you can. If you notice, many classes in the android.* packages have methods that take a Context as a parameter. You, too, can have methods that take a Context as a parameter.

    Now, you will need to document your intended use of the Context and the lifespan of the objects that will touch it, so consumers of your library can pass in an appropriate one. For example, if your library will be creating a static data member that holds onto a SQLiteOpenHelper, you will want to actually have the consumer of the library supply you with an Application, not an Activity, Service, or other Context, so you do not run into garbage collection issues.

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

Sidebar

Related Questions

Possible Duplicate: Where does Android emulator store SQLite database? I am using SQLite and
Possible Duplicate: How to access an existing sqlite database in Android? I've been searching
Possible Duplicate: How to use my own sqlite database? Full Android Database Helper class
Possible Duplicate: Create Excel file in Java How to save output in excel format
Possible Duplicate: How to create Custom Ratings bar in Android The inbuilt rating bar
Possible Duplicate: How can I create a multilingual android application? I am creating application
Possible Duplicate: Using ZXing to create an android barcode scanning app I know it
Possible Duplicate: Create a date with T-SQL I've a data table that stores each
Possible Duplicate: How do I list the tables in a SQLite database file I
Possible Duplicate: tweepy stream to sqlite database - invalid synatx I'm getting a syntax

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.