dimanche 26 juillet 2015

Why SQLite Database not showing in File Explorer in android studio?

in order to working with SQLite in android, I wrote this code:

public class TimeTrackerOpenHelper extends SQLiteOpenHelper {
     private static final int DATABASE_VERSION = 1;

     // Database Name
     private static final String DATABASE_NAME = "timetracker.db";

     public TimeTrackerOpenHelper(Context context) {
           super(context, DATABASE_NAME, null, DATABASE_VERSION);
     }

     @Override
     public void onCreate(SQLiteDatabase db) {
            db.execSQL("create table timerecords " +
                  "(id integer primary key, time text, notes text)");
     }

     @Override
     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
     }
}

and also for instantiating of above class, I added following code to one of my activity class oncreate method:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ListView listView = (ListView) findViewById(R.id.times_list);
    adapter = new TimeTrackerAdapter();
    listView.setAdapter(adapter);

    TimeTrackerOpenHelper openHelper = new TimeTrackerOpenHelper(this);
    Log.d("databaseCreation", openHelper.toString());
    openHelper.close();
} 

For monitoring the result of each query that I send to my timetracker.db, I need to access to my database file. I do the following steps: 1.Run your application. 2.Go to Tools--->Android---->Device Monitor. 3.Find your application name in left panel. 4.Then click on File Explorer tab. 5.Select data folder. 6.Select data folder again and find your app or module name. 7.Click on your database name. 8.On right-top window you have an option to pull file from device. 9.Click it and save it on your PC. 10.Use FireFox Sqlite manager to attach it to your project.

but I have to say that there is not any trace of my .db file. So how can I find that?

Aucun commentaire:

Enregistrer un commentaire