上一篇博客传送门:Android常见问题总结(二)
String path = "数据库路径"; SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(path, null); // 执行sql语句 database.execSQL(sql); // 执行带占位符的sql语句 database.execSQL(sql, bindArgs); // 执行查找的sql语句 database.rawQuery(sql, selectionArgs); // 执行增删查改 database.insert(table, nullColumnHack, values); database.delete(table, whereClause, whereArgs); database.query(table, columns, selection, selectionArgs, groupBy, having, orderBy); database.update(table, values, whereClause, whereArgs); // 开启事务 database.beginTransaction(); // 确认事务成功 database.setTransactionSuccessful(); // 结束事务 database.endTransaction();
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top|center_horizontal"
android:text="text_view"/>
<TextView
android:id="@+id/text_view_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|center_horizontal"
android:text="text_view_2"/>
</FrameLayout>
public class MergeTestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_merge_test);
}
}<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top|center_horizontal"
android:text="text_view"/>
<TextView
android:id="@+id/text_view_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom|center_horizontal"
android:text="text_view_2"/>
</merge>
<ViewStub
android:id="@+id/view_stub"
android:inflatedId="@+id/my_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout="@layout/view_view_stub" />ViewStub viewStub = (ViewStub)findViewById(R.id.view_stub); viewStub.inflate();
原文:http://blog.csdn.net/superxlcr/article/details/51240786