Reputation:
I have created a database named "company"
using android studio. When I want to view the database I created, I can't find it.
I follow the step below
Open DDMS via Tools > Android > Android Device Monitor
and see my project name on the left.
However, when I go to File Explorer,go to /data/data/com.example.project.project, I didn't see the database created which should under database package. There only have two folder there, one is cache
and another is code_cache.
What steps I have missed out? Hope someone can help me to figuring out the problem. Thanks
MyDataBaseHelper.java
package com.example.project.project.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class MyDatabaseHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION=1;
public static final String DATABASE_NAME="Company.db";
public final static String TABLE_NAME="TimeSheet";
public static final String ID="id";
public static final String Name="name";
public static final String Weather="weather";
// public static final String DATABASE_CREATE_TIME_SHEET="create table"+TABLE_NAME+"(+ Name+"TEXT,"+ Weather+"TEXT)";
public void onCreate(SQLiteDatabase db)
{
db.execSQL("create table "+TABLE_NAME+"(name text,weather text)");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion,int newVersion)
{
Log.w(MyDatabaseHelper.class.getName(),"Upgrading database from version"+oldVersion+"to"+newVersion+",which will destroy all old data");
db.execSQL("Drop TABLE IF EXISTS "+TABLE_NAME);
onCreate(db);
}
public MyDatabaseHelper(Context context)
{
super(context, DATABASE_NAME,null,1);
}
}
Upvotes: 1
Views: 716
Reputation: 627
Step 1] Download SQLite Manager in Mozilla Fire Fox.
Step 2] Open Android Device Monitor.
Step 3] Find your Database .
Step 4] Pull your database file to desktop or anywhere.
step 5] Start SQlite Manager from Mozilla.
step 6] Import your database in SQLite Manager.
In SQLite Manager you can see your database ,database table ,records,etc.
Upvotes: 1