android:SQLite数据库没有读写权限
代码:
package entity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
public class DB extends SQLiteOpenHelper {
public DB(Context context) {
super(context, "db_outman", null, 1);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("create table t_contact(_id integer primary key autoincrement, name varchar(50), phone varchar(50)");
db.execSQL("insert into t_contact (name,phone) values('Happy','13589115466')");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
public Cursor findAllContacts()
{
//getWritableDatabase();
SQLiteDatabase db=getReadableDatabase();
Cursor cursor=db.rawQuery("select _id,name,phone from t_contact", null);
return cursor;
}
public void insertContacts(Contact contact)
{
SQLiteDatabase db=getWritableDatabase();
db.execSQL("insert into t_contact(name,phone)values('"+contact.getName()+"','"+contact.getPhone()+"')");
}
public void deleteContacts(int id)
{
SQLiteDatabase db=getWritableDatabase();
db.execSQL("delete from t_contact where _id="+id);
}
}
报错行:
db.execSQL("create table t_contact(_id integer primary key autoincrement, name varchar(50), phone varchar(50)");
db.execSQL("insert into t_contact (name,phone) values('Happy','13589115466')");
报错信息:
数据库没有写权限,如何修改呢?
------解决方案--------------------配置文件中申请SD卡的操作权限了吗?
<!-- 在SDCard中创建与删除文件权限 -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>