Retrieving data 检索数据
Retrieving data from SQLite databases in Android is done using Cursor. The Android SQLite query method returns a Cursor object containing the results of the query. To use Cursor android.database.Cursor must be imported.
在安卓中使用Cursor接口来从SQLite database 中检索数据。SQLite 查询返回的Cursor包含查询所得结果的Cursor对象。使用Cursor时应当导入android.databaseCursor包。
About Cursor 关于Cursor
Cursor store query result records in rows and grant many methods to access and iterate through the records. Cursor should be closed when no longer used, and will be deactivated with a call to Cursor.deactivate() when the application pauses or exists. On resume the Cursor.requery() statement is executed to re-enable the Cursor with fresh data. These functions can be managed by the parent Activity by calling startManagingCursor().
Cursor将查询结果记录存放在列中,并且提供了许多方法来访问和迭代这些记录。如果Cursor不再使用的时候应当关闭掉,并且当应用程序暂停或者滞留时应当调用Cursor.deactivate()来使Cursor失效。在应用程序继续运行时,Cursor.requery()用来重新启动数据更新之后的Cursor。这些函数由父Activity调用startManagingCursor()进行管理。
package higherpass.TestingData;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.content.ContentValues;