1

Due to your solutions I have finished my application, I came here for last question about my current application, the database I created I am not able to access it, I read that is within the system of android so what should I do to access the database and export it ?

 public class DBAdapter {
 private static final String DATABASE_NAME = "bd";
 private static final int DATABASE_VERSION = 3;
 private final Context context;
 private static DatabaseHelper  DBHelper;
 private SQLiteDatabase db;
 static String SqlCreate = "CREATE TABLE password(id INTEGER, name TEXT, password TEXT)";
 public DBAdapter(Context ctx) {
     this.context = ctx;
     DBHelper = new DatabaseHelper(context);
 }

 public void onOpen(SQLiteDatabase db) {
db = DBHelper.getWritableDatabase();
// super.onOpen(db);
 if (!db.isReadOnly()) {
 // Enable foreign key constraints
 db.execSQL("PRAGMA foreign_keys=ON;");
 }
 }
private static  class DatabaseHelper extends  SQLiteOpenHelper {
      DatabaseHelper (Context context) {
         super(context,DATABASE_NAME,null,DATABASE_VERSION);
      }
   public void onCreate(SQLiteDatabase db) {
    try {
           db.execSQL(DATABASE_CREATE1);
           db.execSQL(DATABASE_CREATE3);
           db.execSQL(SqlCreate);
          // db.execSQL(DATABASE_CREATE2);

        }  
        catch(SQLException e) {
        e.printStackTrace();
        }
   }
2
  • Do you want to export the data from an external source to Android, or from Android to an external source? Or something else entirely? Commented Nov 13, 2013 at 17:08
  • the second idea, to make database to external source Commented Nov 13, 2013 at 17:13

3 Answers 3

2

If i get your question right you should use Android Device Monitor. In Android Studio go to:

Tools -> Android - > Android Monitor.

With the emulator running you can access the database in:

data->data->com.your.application/databases/databasename

You can export it from there.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for answer, but i already knew that, i want to access my database in my phone not in the simulator.
I am unable to see data > data . My data folder have no subfolders . What I am doing wrong? please help
2

There is a library called Android Debug Database

It's really simple and easy to use,Android Debug Database allows you to view databases and shared preferences directly in your browser in a very simple way.

To use the library just add

debugImplementation 'com.amitshekhar.android:debug-db:1.0.3'

to your app's build.gradle. That's it now you can access or export your database by browsing to the provided localhost link. If you want different port add this

debug {
    resValue("string", "PORT_NUMBER", "8081")
}

It will look like this, nice UI too!

you can find more detailes information in the given link below. https://github.com/amitshekhariitbhu/Android-Debug-Database#android-debug-database

Comments

0

In eclipse, you can use the DDMS tab to view SQLite database.

Go to file explorer and click on your device -> data -> data -> package name -> database name

You can now push or pull the database... You can also use adb...

To access your database on a non rooted phone, you have to use adb backup to realise a backup of your database. exemple here : http://dbremes.wordpress.com/2013/02/11/how-to-get-a-backup-of-your-android-applications-database-in-windows/

You must first realise the backup and get a .ab file and next extract the database from the backup file.

1 Comment

thanks for answer, but i already knew that, i want to access my database in my phone not in the simulator.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.