SQLite数据库在我的文件探讨的Android无法创建 [英] sqlite database not create in my file explore android
本文介绍了SQLite数据库在我的文件探讨的Android无法创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友你好我wnat OT通过创建查询源码DATABSE所以我下面写code为
hello friends i wnat ot create sqlite databse by query so i write below code for that
public class DBHandler extends SQLiteOpenHelper {
// All Static variables
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "abc";
// Contacts table name
private static final String TABLE_CONTACTS = "user";
// Contacts Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_EMAIL = "email";
private static final String KEY_NAME = "pin";
private static final String KEY_PH_NO = "key";
public DBHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
System.out.println("Call");
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_EMAIL + " TEXT,"+ KEY_NAME + " TEXT,"
+ KEY_PH_NO + " TEXT" + ")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_CONTACTS);
// Create tables again
onCreate(db);
}
}
Main.java
public class AndroidSQLiteTutorialActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DatabaseHandler db = new DatabaseHandler(this);
}
}
当我运行上面code它不会产生在我的文件数据库探索我的仿真器选项的任何想法如何我可以解决?所有的建议都适用
When i run above code it will not create database in my file explore option of my emulator any idea how can i solve? your all suggestions are applicable
推荐答案
您可以找到您创建的数据库,名为
You can find your created database, named
在
/data/data/<Your-Application-Package-Name>/databases/<your-database-name>
将其拉出使用文件资源管理器,并重新命名它有.db3扩展在SQLiteExplorer使用它
Pull it out using File explorer and rename it to have .db3 extension to use it in SQLiteExplorer
DDMS使用文件资源管理器浏览到emulator目录。
Use File explorer of DDMS to navigate to emulator directory.
这篇关于SQLite数据库在我的文件探讨的Android无法创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文