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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:10:38+00:00 2026-05-20T03:10:38+00:00

I am working on an Android application, where some of the functions that users

  • 0

I am working on an Android application, where some of the functions that users should input: register, locate hospital location, search for messages (sent via sms to registered users) and can schedule and make appointments.

So far, all the activities are done. However, I need to know how to connect to the database in order to read and store this data. I am using Android 2.1, Mac OS X, and the SQLite Firefox extension.

This is the code I have to connect to the SQLite database, what am I doing wrong?

package com.bitnuts.imom;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DbManager extends SQLiteOpenHelper {

    private static final String DB_NAME = "iMom.sqlite";
    private static final String DB_PATH = "/data/data/com.bitnuts.imom/databases/";
    private static final Integer DB_VERSION = 1;
    private static final String TAG = "DbManager";
    private final Context context;
    private SQLiteDatabase db;
    private DbManager dbManager;

    public DbManager(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        this.context = context;
    }

    public DbManager open() {
        dbManager = new DbManager(context);
        db = dbManager.getWritableDatabase();
        return this;
    }

    @Override
    public void onCreate(SQLiteDatabase arg0) {

        createNewDatabase();
    }

    @Override
    public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {

        // TODO Auto-generated method stub
    }

    public void createNewDatabase() {
        InputStream assetsDB = null;
        try {
            assetsDB = context.getAssets().open(DB_NAME);
            OutputStream dbOut = new FileOutputStream(DB_PATH + DB_NAME);

            byte[] buffer = new byte[1024];
            int length;
            while ((length = assetsDB.read(buffer)) > 0) {
                dbOut.write(buffer, 0, length);
            }

            dbOut.flush();
            dbOut.close();
            assetsDB.close();
        }
        catch (IOException e) {
        }
    }
}
  • 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-20T03:10:39+00:00Added an answer on May 20, 2026 at 3:10 am

    You cannot use the SQLite database directly in your application. You need to make some modifications. Such as the android_metadata table, etc. The blog post Using your own SQLite database in Android applications will help you.

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

Sidebar

Related Questions

I'm currently working my way through the book Teach Yourself Android Application Development in
I am working android application my problem is i am using handlers this handler
I am writing my first Android application and have some problems with handing around
I have the following problem: I am working on an Android application where at
I'm working on a high-performance Android application (a game), and though I try to
I've been working on the Android SDK platform, and it is a little unclear
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a project that parses a log of events, and then updates a
Working with python interactively, it's sometimes necessary to display a result which is some
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB.

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.