1
我想在我的手機找我的數據庫(HTC M7)哪裏可以找到Sqlite數據庫?
其實,當我使用索尼移動,我可以找到它
但現在既然我改變HTC M7
我不能找到它這是我的數據路徑設置
哪裏可以找到它在HTC M7?
import static android.provider.BaseColumns._ID;
import java.io.File;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Environment;
public class DBHelper extends SQLiteOpenHelper {
private static Context context;
public static final String TABLE_NAME = "Gsensor"; //sqlite table name
public static final String X = "X";
public static final String Y = "Y";
public static final String Z = "Z";
private final static String DATABASE_NAME = "Gsensor.db"; //database name
private final static int DATABASE_VERSION = 1; //db ver
private File path = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +
File.separator); //db path
String filepath = Environment.getExternalStorageDirectory().getAbsolutePath() +
File.separator + "Gsensor.db";
private File f = new File(filepath);
//DB table
String CreateTable = "CREATE TABLE " + TABLE_NAME + " (" +_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
X + " CHAR, " + Y + " CHAR, " + Z + " CHAR);";
//del table
String DelTable = "DROP TABLE IF EXISTS " + TABLE_NAME;
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
this.context = context;//openOrCreateDatabase is this method
//so need to init context and return to
}
@Override
//create table
public void onCreate(SQLiteDatabase db) {
SQLiteDatabase dbwrite= context.openOrCreateDatabase("f", context.MODE_WORLD_WRITEABLE, null);
db.execSQL(CreateTable);
}
@Override
//del table
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(DelTable);
onCreate(db);
}
}
爲什麼不是'Gsensor.db'在默認的'/數據/數據/ your.app.name/databses /'路徑? –
@DerGolem此預設路徑,如果我想在此路徑中找到它,我的手機需要root,但我不想root。 –
因此,您的用戶可以在需要時將其刪除。尼斯。 –