在Android设备监视器中找不到数据库

时间:2016-01-15 03:02:00

标签: java android database sqlite

我是SQlite数据库的新手,我正在尝试构建一个。我希望能够查看我的数据库,但是当我打开Android设备监视器并转到Data / Data / com.package.example我只找到空白文件夹;没有数据库文件夹。

这是我的主Java文件:

package ca.software.appart.zoomlist;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;



public class New_Recipe extends AppCompatActivity{
DatabaseHelper Recipedb;
Button add,done;
EditText Recipe_Name,Recipe_Item;
String search;

WebView webView;
TextView textView;




@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new__recipe);
    setTitle("New Recipe");
    add = (Button) findViewById(R.id.button2);
    done = (Button) findViewById(R.id.button);
    Recipe_Name = (EditText) findViewById(R.id.editText);
    Recipe_Item = (EditText) findViewById(R.id.editText2);
    webView = (WebView) findViewById(R.id.webView);
    textView = (TextView) findViewById(R.id.textView);
    Recipedb = new DatabaseHelper(this);

      }

public void onNewRecipeClick (View v) {

}
public void onSearch(View v) {
    search = "Recipes";
    webView.loadUrl("https://www.google.com/search?q="+search);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_new__recipe, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
}

这是我的DatabaseHelper Java文件:

package ca.software.appart.zoomlist;

 import android.content.Context;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;


 public class DatabaseHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "Recipes";
public static final String TABLE_NAME = "Recipe_Table";
public static final String COL1 = "Name";
public static final String COL2 = "Items";
public static final String COL3 = "Steps";

public DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();

}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("Create table " + TABLE_NAME +"("+COL1+"INTEGER PRIMARY KEY ,"+COL2+"TEXT,"+COL3+"TEXT)");

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME);
    onCreate(db);

}
}

我希望有人可以提供帮助!

0 个答案:

没有答案