The following code just worked for me on the emulator (android 2.1):

                File f1 = Environment.getExternalStorageDirectory();
                Log.v(TAG, f1.getAbsolutePath());
                
                String dbFilePath = f1.getAbsolutePath() + File.separator + 
"extdir.db";
                Log.v(TAG, dbFilePath);
                
                SQLiteDatabase db = SQLiteDatabase.openDatabase(dbFilePath, 
null, SQLiteDatabase.CREATE_IF_NECESSARY);
                Log.v(TAG, "db.isOpen() = " + db.isOpen());
                db.close();

I created a new project with the default activity and dropped the above 
code into the end of it's onCreate() method.

I changed the manifest to the have the following two lines just above the 
<application> element
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission 
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

The android target was 7 (which is android 2.1)

On Thursday, May 17, 2012 8:53:24 PM UTC+1, chronogps wrote:
>
> I made a mistake : the problem is under Android 2.1
>
> The log cat under 2.1 Emulator is :
>
> 05-17 19:43:06.536: E/Database(245): 
> sqlite3_open_v2("/mnt/sdcard/chronogps.db", &handle, 6, NULL) failed
> 05-17 19:43:06.536: W/dalvikvm(245): threadid=15: thread exiting with 
> uncaught exception (group=0x4001b188)
> 05-17 19:43:06.556: E/AndroidRuntime(245): Uncaught handler: thread 
> Thread-8 exiting due to uncaught exception
> 05-17 19:43:06.566: E/AndroidRuntime(245): 
> android.database.sqlite.SQLiteException: unable to open database file
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1697)
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738)
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:760)
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> com.ActivationChronogps.ListeClient$3.run(ListeClient.java:390)
> 05-17 19:43:06.566: E/AndroidRuntime(245): at 
> java.lang.Thread.run(Thread.java:1096)
> 05-17 19:43:06.596: I/dalvikvm(245): threadid=7: reacting to signal 3
> 05-17 19:43:06.596: E/dalvikvm(245): Unable to open stack trace file 
> '/data/anr/traces.txt': Permission denied
>
> I tried on 2.2 Emulator and on my Motorola Defy under 2.2 : no problem.
>
> Maybe a bug fixed since 2.2
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to