I want look for my database in my mobile (HTC M7)
Actually when I use sony mobile I can find it
But now I can't find it since I change HTC M7
This is my data path set up
And where can find it in 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);
}
}
Aucun commentaire:
Enregistrer un commentaire