1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.UserDictionary;
import android.util.Log;
public class WordsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("TAG","++ oncreate ++");
setContentView(R.layout.main);
final String[] QUERY_PROJECTION = {
UserDictionary.Words._ID,
UserDictionary.Words.WORD,
UserDictionary.Words.LOCALE
};
Cursor cursor = getContentResolver()
.query(UserDictionary.Words.CONTENT_URI,
QUERY_PROJECTION,
UserDictionary.Words.WORD+" =?",
new String[] { "Book" }, null);
int index = cursor.getColumnIndex(UserDictionary.Words.WORD);
if (cursor != null) {
while (cursor.moveToNext()) {
String newWord = cursor.getString(index);
Log.d("TAG","word="+newWord);
}
Log.d("TAG","après while");
}else{
Log.d("TAG","cursor est null");
}
}
} |
Partager