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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:38:33+00:00 2026-06-03T09:38:33+00:00

I want to learn how to program databases for Android and to my knowledge

  • 0

I want to learn how to program databases for Android and to my knowledge that is SQLite. If I know Java what else do I need to learn so that I can build a database? Any other information that you could help me with would be appreciated.

  • 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-03T09:38:34+00:00Added an answer on June 3, 2026 at 9:38 am

    Basically, you need a DatabaseHelper class, example of DataBaseHelper.class:

    import java.util.ArrayList;
    
    import android.content.ContentValues;
    import android.content.Context;
    
    import android.database.Cursor;
    import android.database.SQLException;
    
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteException;
    
    import android.database.sqlite.SQLiteOpenHelper;
    public class DBHelper extends SQLiteOpenHelper{
    
    private String sql;
    private SQLiteDatabase db;
    
    //database name
    private static final String NAME_DB = "Courses.sql";    
    
    //database version
    private static final int VERSION_DB = 1;
    
    //database table name
    public static final String COURSES_TABLE = "courses";
    
    //database table columns for N_TABLE
    public static final String ID_KEYROW= "_id";
    public static final String ID_COURSE= "courseid";
    public static final String ID_TITLE = "title";
    public static final String ID_INSTRUCTOR = "instructor";
    public static final String ID_LENGTH = "length";
    public static final String ID_RATING = "rating";
    public static final String ID_TOPIC = "topic";
    public static final String ID_SUBJECT = "subject";
    public static final String ID_DESCRIPTION = "description";  
    //private final Context myContext;
    
    public DBHelper(Context context) {
        super(context, NAME_DB, null, VERSION_DB);
        //this.myContext = context;
    }
    //Creating Table
    @Override
    public void onCreate(SQLiteDatabase db) 
    {
        String CREATE_LOGIN_TABLE = "CREATE TABLE " + COURSES_TABLE + "("
                + ID_KEYROW + " INTEGER PRIMARY KEY AUTOINCREMENT, "
                + ID_COURSE + " TEXT NOT NULL, "
                + ID_TITLE + " TEXT NOT NULL, "
                + ID_INSTRUCTOR + " TEXT NOT NULL, "
                + ID_LENGTH + " TEXT NOT NULL, "
                + ID_RATING + " TEXT NOT NULL, "
                + ID_TOPIC + " TEXT NOT NULL, "
                + ID_SUBJECT + " TEXT NOT NULL, "
                + ID_DESCRIPTION + " TEXT NOT NULL" + ")";
        db.execSQL(CREATE_LOGIN_TABLE);
        /* Other Method for Create DataBase.
        db.execSQL(" CREATE TABLE courses" + "(" + ID_KEYROW + " INTEGER PRIMARY KEY AUTOINCREMENT, " + ID_COURSE + " TEXT NOT NULL, " + ID_TITLE + " TEXT NOT NULL, " + ID_INSTRUCTOR + " TEXT NOT NULL, " + ID_LENGTH + " TEXT NOT NULL, " + ID_RATING + " TEXT NOT NULL, " + ID_TOPIC + " TEXT NOT NULL, " + ID_SUBJECT + " TEXT NOT NULL, " + ID_DESCRIPTION + " TEXT NOT NULL);"
                );*/    
    }       
    
    //Updating Database
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    
        db.execSQL("DROP TABLE IF EXISTS " + COURSES_TABLE);
        onCreate(db);
    }
    //Insert Courses
    //public void insertCourses(Integer courseid, String title, String instructor, Integer length, Integer rating, String topic, String subject, String description)
    public void insertCourses()
    {
        SQLiteDatabase db= this.getWritableDatabase();
    
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('1', 'Interdisciplinary Care Planning', 'Keith Savell', '60', '4.7', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to...', 'Encourage the Interdisciplinary Treatment Team (IDT) to work as a team and view the Care Plan as a resident-centered collaborative effort  to enhance the care and quality of resident life.', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to utilize the Care Plan to truly function as a team - working together to enhance the care and quality of resident life.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('2', 'Culture Change: Creating A Climate Of Care...', 'Keith Savell', '60', '5', 'Culture Change ', 'Learn to evaluate and modify the environment to support our residents with cognitive impairment as they age in place.', 'Residents with dementia and delirium are constantly assessing the environment, looking for clues to help them understand where they are, who others around them are, what they are supposed to be doing and what is expected of them.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('3', 'Medical Records Documentation', 'Keith Savell', '60', '5', 'Medical Records Documentation ', 'Encourage the Interdisciplinary Treatment Team (IDT) to work as a team and view the Care Plan as a resident-centered collaborative effort  to enhance the care and quality of resident life.', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to utilize the Care Plan to truly function as a team - working together to enhance the care and quality of resident life.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('4', 'Census Challenges', 'Keith Savell', '60', '4.45', 'Creative Solutions to Drive Census ', 'Learn to evaluate and modify the environment to support our residents with cognitive impairment as they age in place.', 'Residents with dementia and delirium are constantly assessing the environment, looking for clues to help them understand where they are, who others around them are, what they are supposed to be doing and what is expected of them.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('5', 'Fall Prevention: Reducing Fall Related Injuries', 'Keith Savell', '60', '5', 'Guidelines for Health Care Providers ', 'Encourage the Interdisciplinary Treatment Team (IDT) to work as a team and view the Care Plan as a resident-centered collaborative effort  to enhance the care and quality of resident life.', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to utilize the Care Plan to truly function as a team - working together to enhance the care and quality of resident life.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('6', 'Meaningful Engagement', 'Keith Savell', '60', '5', 'Creating The Failure Free Activity Program ', 'Learn to evaluate and modify the environment to support our residents with cognitive impairment as they age in place.', 'Residents with dementia and delirium are constantly assessing the environment, looking for clues to help them understand where they are, who others around them are, what they are supposed to be doing and what is expected of them.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('7', 'Dementia and Delirium', 'Keith Savell', '60', '4.69', 'The Importance of Accurate Diagnosis and Treatment ', 'Encourage the Interdisciplinary Treatment Team (IDT) to work as a team and view the Care Plan as a resident-centered collaborative effort  to enhance the care and quality of resident life.', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to utilize the Care Plan to truly function as a team - working together to enhance the care and quality of resident life.')";
        db.execSQL(sql);
        sql="INSERT INTO courses(courseid, title, instructor,  length, rating, topic, subject, description) VALUES ('8', 'Delirium', 'Keith Savell', '60', '4.69', 'The Importance of Accurate Diagnosis and Treatment ', 'Encourage the Interdisciplinary Treatment Team (IDT) to work as a team and view the Care Plan as a resident-centered collaborative effort  to enhance the care and quality of resident life.', 'Interdisciplinary Care Planning requires members of the Interdisciplinary Treatment Team (IDT) to view the Care Plan as a resident centered collaborative effort - rather than as a staff centered document. Learn how to utilize the Care Plan to truly function as a team - working together to enhance the care and quality of resident life.')";
        db.execSQL(sql);
    
        //Other Style for Insert record in DB.
        ContentValues values = new ContentValues(); //Here from ContentValues
        values.put("courseid", "9");
        values.put("title", "xxxxxxx Care Planning");
        values.put("instructor", "Keith Savell");
        values.put("length", "60");
        values.put("rating", "4.7");
        values.put("topic", "some topic");
        values.put("subject", "some subject");
        values.put("description", "some description");
        db.insert(COURSES_TABLE, null, values);
    }
    
    public ArrayList<Courses> getCourses()
    {
        db = getWritableDatabase();
        sql = "SELECT courseid, title, instructor, length, rating, topic, subject, description FROM courses";
        Cursor cursor = db.rawQuery(sql, null);
        ArrayList<Courses> courses = new ArrayList<Courses>();
    
    
        while (cursor.moveToNext())
        {
            Courses oCourses=new Courses();
    
            oCourses.courseid=cursor.getInt(0);
            oCourses.title=cursor.getString(1); //Original Value 0
            oCourses.instructor=cursor.getString(2);
            oCourses.length=cursor.getString(3);
            oCourses.rating=cursor.getString(4);
            oCourses.topic=cursor.getString(5);
            oCourses.subject=cursor.getString(6);
            oCourses.description=cursor.getString(7);
            courses.add(oCourses);          
        }       
        db.close();
        cursor.close();
        return courses;     
    }
    
    public ArrayList<Courses> getItem(int position)
    {
        db = getWritableDatabase();
        sql = "SELECT courseid, title, instructor, length, rating, topic, subject, description FROM courses";
        Cursor cursor = db.rawQuery(sql, null);
        ArrayList<Courses> courses = new ArrayList<Courses>();
    
    
        while (cursor.moveToNext())
        {
            Courses oCourses=new Courses();
    
            oCourses.courseid=cursor.getInt(0);
            oCourses.title=cursor.getString(1); //Original Value 0
            oCourses.instructor=cursor.getString(2);
            oCourses.length=cursor.getString(3);
            oCourses.rating=cursor.getString(4);
            oCourses.topic=cursor.getString(5);
            oCourses.subject=cursor.getString(6);
            oCourses.description=cursor.getString(7);
            courses.add(oCourses);          
        }
        db.close();
        cursor.close();
        return courses;
    
    }
    
    public int getRowCount() {
        String countQuery = "SELECT * FROM " + COURSES_TABLE;
        SQLiteDatabase db =this.getReadableDatabase();
        Cursor cursor = db.rawQuery(countQuery, null);
        int rowCount = cursor.getCount();
        db.close();
        cursor.close();
        //return row count.
        return rowCount;
    }//GetRowCount
    
    //Recreate database, delete all tables and create them again.
     public void resetTables(){
            SQLiteDatabase db = this.getWritableDatabase();
            // Delete All Rows
            db.delete(COURSES_TABLE, null, null);
            db.close();
        }}
    

    Later in your Mainclass (or activity you want to manage the data) call methods of your DatabaseHelper.class, Hope this give you ideas…

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

Sidebar

Related Questions

I want to learn Delphi, does anyone know of a good free program that
I want to learn to write a thread pool in Java Can anyone point
I want to learn C++ so that i can develop C++ Python modules for
I don't know what they're called but I want to learn to program bots
I know that CAS is of limited value , but I want to learn
I want to learn to program in a UNIX/Linux environment. I'll be using the
TL DR; Want some Java help with connecting to a truly local database (
I want to learn to program the canvas element. Anyone got any recommendations of
If want to learn how to program n-Tiered/Distributed applications in .net, what technology should
What i want to learn is when program loads it comes up with the

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.