I am new to SQlite databases and I am trying to build one. I would like to be able to view my database but when ever I open the Android Device Monitor and go to Data/Data/com.package.example I only find blank folders; no Database folder.
Here's my Main Java file:
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("http://ift.tt/vgrAeu"+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);
}
}
Here's my DatabaseHelper Java file:
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);
}
}
I hope someone can help!
Aucun commentaire:
Enregistrer un commentaire