I'm following the Android Developers tutorial to create a BD: link
I use Android Studio 2.2.3 and an Alcatel Pixi 4 with Android 6.0 for testing. When you run the App you just have to create a BD with a table and insert a record, on the device the App screen appears with the typical Hello world. The problem is that I do not see the file with the BD in the ADM / DDMS In the File explorer the directory "data /" only contains a file "default.pro"
These are the classes with the code:
// MainActivity.java
package com.example.orici.dbtest;
import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView( R.layout.activity_main );
FeedReaderDbHelper mDbHelper = new FeedReaderDbHelper( this );
SQLiteDatabase db = mDbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_TITLE, "Mi título");
values.put(FeedReaderContract.FeedEntry.COLUMN_NAME_SUBTITLE, "Unas pruebas");
long newRowId = db.insert(
FeedReaderContract.FeedEntry.TABLE_NAME, null, values
);
}
} //class
// FeedReaderContract.java
package com.example.orici.dbtest;
import android.provider.BaseColumns;
public final class FeedReaderContract {
private static final String TEXT_TYPE = " TEXT";
private static final String COMMA_SEP = ",";
protected static final String SQL_CREATE_ENTRIES =
"CREATE TABLE " + FeedEntry.TABLE_NAME + " (" +
FeedEntry._ID + " INTEGER PRIMARY KEY," +
FeedEntry.COLUMN_NAME_TITLE + TEXT_TYPE + COMMA_SEP +
FeedEntry.COLUMN_NAME_SUBTITLE + TEXT_TYPE + " )";
protected static final String SQL_DELETE_ENTRIES =
"DROP TABLE IF EXISTS " + FeedEntry.TABLE_NAME;
private FeedReaderContract() {}
// Inner class that defines the table contents
public static class FeedEntry implements BaseColumns {
public static final String TABLE_NAME = "entry";
public static final String COLUMN_NAME_TITLE = "title";
public static final String COLUMN_NAME_SUBTITLE = "subtitle";
} //class
} //class
//FeedReaderDbHelper.java
package com.example.orici.dbtest;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static com.example.orici.dbtest.FeedReaderContract.SQL_CREATE_ENTRIES;
public class FeedReaderDbHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "FeedReader.db";
public FeedReaderDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL( FeedReaderContract.SQL_CREATE_ENTRIES );
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL( FeedReaderContract.SQL_DELETE_ENTRIES );
onCreate(db);
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
onUpgrade(db, oldVersion, newVersion);
}
} //class