kamiseq,
Only just saw your posts.
I have to regularly create db's on sdCard due to my requirements. The
code I use is below.
The main thing that stands out in your code to me is
File.pathSeparator, from memory this returns ":" when you need
File.separator which is "/" - on my system anyhow.
/**
* Opens the SDcard database. </br > If it cannot be opened, it
creates a
* new instance.</br> If a new instance cannot be created, it throws
an
* exception and logs the failure.
*
* @return true if successful
* @throws SQLException
* if the database is unable to be opened or created
*/
protected synchronized boolean open() throws SQLException {
if (mDb != null && mDb.isOpen()) {
return true;
} else {
StringBuilder builder = mBuilder;
// open or create a new directory
builder.setLength(0);
builder.append(Environment.getExternalStorageDirectory())
.append(File.separator)
.append(getPackageName());
File directory = new File(builder.toString());
directory.mkdirs();
builder.setLength(0);
builder.append(directory.getAbsolutePath())
.append(File.separator)
.append(DATABASE_NAME);
String fullPathName = builder.toString() ;
try {
Log.d(TAG, "Opening database: " +
fullPathName); //$NON-NLS-1$
mDb =
SQLiteDatabase.openOrCreateDatabase(fullPathName, null);
createTables();//my sql statement to create
tables if not exist
} catch (SQLException e) {
Log.e(TAG, "failed to open" + e);
throw e;
}
}
return true;
}
--
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