问题描述:

I am trying to create database in External Micro SD Card not in SD Card .

It is showing this error:

Caused by: java.lang.IllegalArgumentException: File mounted/extSdCard/mytest contains a path separator

I am passing this path.

The same works for SD Card .but not for my Extenally Micro sd card.

public SDcardDatabase(final Context context) {

super(context,Environment.getExternalStorageState()+"/extSdCard/mytest", null, 1);

}

I am writing data like this:-

public void saveData(View v) {

SQLiteDatabase sqldb = null;

SDcardDatabase mydb = new SDcardDatabase(this);

sqldb = mydb.getWritableDatabase();

ContentValues insertData = new ContentValues();

insertData.put(SDcardDatabase.NAME, etname.getText().toString());

insertData.put(SDcardDatabase.ADDRESS, etadd.getText().toString());

insertData.put(SDcardDatabase.CITY, etcity.getText().toString());

sqldb.insert("mylistdata", SDcardDatabase.NAME , insertData);

sqldb.close();

Toast.makeText(this,"Data saved", Toast.LENGTH_SHORT).show();

}

网友答案:
java.lang.IllegalArgumentException: File mounted/extSdCard/mytest contains a path separator

you should go to this question, which will probably solve your problem as well:

You should supply a name of File, not Full path as your Argument.

The documentation also indicates this about the name parameter of the function:

The name of the file to open can not contain path separators.

相关阅读:
Top