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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:24:12+00:00 2026-06-18T00:24:12+00:00

I want to know one thing in android sqlite. I created my database in

  • 0

I want to know one thing in android sqlite.

I created my database in sdcard. so there is no `upgrage() method.

public class DatabaseClass
{
    public static final String  DATABASE_FILE_PATH = "/sdcard";
    public static final String  DATABASE_NAME = "testDatabase";

    public static final String TRACKS_TABLE_CREATE =
        "create table if not exists casecategory (_id INTEGER primary key autoincrement, "
        + "category_name TEXT not null);";

    public SQLiteDatabase database;

    public DatabaseClass()
    {  
        try
        {
            database = SQLiteDatabase.openOrCreateDatabase(DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null);
            createTables();
        }

        catch (SQLiteException ex)
        {
            Log.e("Hello", "error -- " + ex.getMessage(), ex);
        }
        finally
        {
            database.close();
        }
    }

in internal memory we create like :-

public class DatabaseClass extends SQLiteOpenHelper 
{
    /*Constants */
    public final static String DATABASE_NAME ="localdbfile.db";
    public final static String NAME ="name";
    public final static String ADDRESS ="address";


    public final static String CITY ="city";

    public DatabaseClass(Context context) {
        super(context, DATABASE_NAME, null, 1);
        // TODO Auto-generated constructor stub
        }

    @Override
    public void onCreate(SQLiteDatabase db) {
    db.execSQL( "CREATE TABLE mylistdata(_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT, address TEXT,city TEXT);");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP Table mylistdata");
        onCreate(db);

    }

}

in internal memory we change the version number and upgrade() called. which upgrade the DB.

if i want to upgrade database version in sdcard database.

how can i do this ,if possible.

  • 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-18T00:24:13+00:00Added an answer on June 18, 2026 at 12:24 am

    You can store your database directly in SD card like this:

    static class DatabaseClass extends SQLiteOpenHelper {
    
        DatabaseClass(final Context context) {
            super(context, Environment.getExternalStorageDirectory()
                    + File.separator + "/DataBase/" + File.separator
                    + DATABASE_NAME, null, DATABASE_VERSION);
        }
    

    If you store ur databse in internal memory then you can also copy the database from internal memory to SD card 🙂

    Here’s an example how to copy data to SD card:

    InputStream myInput = new FileInputStream("/data/data/pack_name/databases/databasename.db");
    
    File directory = new File("/sdcard/some_folder");
    if (!directory.exists()) {
        directory.mkdirs();
    }
    
    OutputStream myOutput = new FileOutputStream(directory.getPath() + "/AppName.backup");
    
    byte[] buffer = new byte[1024];
    int length;
    while ((length = myInput.read(buffer)) > 0) {
        myOutput.write(buffer, 0, length);
    }
    
    myOutput.flush();
    myOutput.close();
    myInput.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to google maps android api, and there is one thing I want
I have a SQLite database in android with some tables, one of them is
I just want to know one thing.. I have a client who has complaint
I want to know which one is stable, fast and easy to use?
I Want to know which one is preferred while coding to use Static Methods
I want to know that how one should proceed in building animated splash screen.
HI, i need a XML parser. i want to know that which one is
i have one domain link text i want to know that does google crawl
I just want to know how to code a animation like the one on
I want to know how to create a label that contains two icons, one

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.