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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:26+00:00 2026-06-17T22:46:26+00:00

why my database giving error.please assist me:- i am creating my database in sdcard

  • 0

why my database giving error.please assist me:- i am creating my database in sdcard.

where i am doing mistake.

public class SDcardDatabase extends SQLiteOpenHelper
{

    public static final String  DATABASE_FILE_PATH = "/sdcard";
    public static final String  DATABASE_NAME = "testDatabase";
    public final static String NAME ="name";
    public final static String ADDRESS ="address";
    public final static String CITY ="city";

    public SDcardDatabase(final Context context) {
        super(context,Environment.getExternalStorageDirectory()+File.separator+DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null, 1);
    }


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

        }

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

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

and calling this in activity.

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mydb = new SDcardDatabase(this);
        sqldb = mydb.getWritableDatabase();
        sqldb.close();
    }

error log:-

01-29 10:03:46.534: W/dalvikvm(8185): threadid=1: thread exiting with uncaught exception (group=0x40014760)
01-29 10:03:46.548: E/AndroidRuntime(8185): FATAL EXCEPTION: main
01-29 10:03:46.548: E/AndroidRuntime(8185): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sdcard/com.example.sdcard.SDcardDBActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.os.Looper.loop(Looper.java:126)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread.main(ActivityThread.java:3997)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at java.lang.reflect.Method.invoke(Method.java:491)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at dalvik.system.NativeStart.main(Native Method)
01-29 10:03:46.548: E/AndroidRuntime(8185): Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:978)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:951)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1016)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:726)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:221)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:149)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at com.example.sdcard.SDcardDBActivity.onCreate(SDcardDBActivity.java:20)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-29 10:03:46.548: E/AndroidRuntime(8185):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
  • 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-17T22:46:27+00:00Added an answer on June 17, 2026 at 10:46 pm

    try adding :

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my Database Table which is giving Error.. Foreign key Define in more
I'm trying to insert a record into the database but it is giving me
I am getting following error each time I tried to select database. The database
The python manage.py syncdb command is giving me the following error: sqlite3.OperationalError: unable to
// This is the file that is giving the error, not the form below
I get the following error while implementing rake db:migrate rake aborted! Please install the
I'm trying to retrive data from android sqlite database but its givine exception that
database name customdata jobNo CustomerName Country Tel Item 1 John USA 045 Mouse 2
Database is like: table book: book_id, title table wrote: book_id, author_id, author_order table author:
Database : Oracle 11g VS 20120 Provider: ODAC 11.2 Release 4 and Oracle Developer

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.