07-29 05:43:22.256 3308-3308/com.example.sharecorn.wordydictionary D/DICTIONARY: Initialized for the first time
07-29 05:43:22.392 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 4855K, 24% free 15901K/20888K, paused 3ms+1ms, total 9ms
07-29 05:43:22.516 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 3713K, 21% free 16560K/20888K, paused 2ms+1ms, total 10ms
07-29 05:43:22.644 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 3894K, 19% free 17259K/21288K, paused 2ms+1ms, total 10ms
07-29 05:43:22.784 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 4181K, 20% free 18020K/22340K, paused 2ms+0ms, total 15ms
07-29 05:43:22.784 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 8ms
07-29 05:43:22.920 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 4293K, 19% free 18936K/23244K, paused 1ms+1ms, total 12ms
07-29 05:43:23.080 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 4668K, 19% free 19943K/24480K, paused 2ms+4ms, total 28ms
07-29 05:43:23.244 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 5098K, 19% free 21035K/25836K, paused 1ms+1ms, total 22ms
07-29 05:43:23.428 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 5568K, 20% free 21846K/27276K, paused 1ms+1ms, total 18ms
07-29 05:43:23.576 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 5620K, 20% free 22842K/28388K, paused 1ms+0ms, total 18ms
07-29 05:43:23.748 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 5909K, 20% free 239 07K/29696K, paused 2ms+1ms, total 20ms
07-29 05:43:23.944 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 6264K, 21% free 24772K/31204K, paused 1ms+0ms, total 17ms
07-29 05:43:23.944 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 9ms
07-29 05:43:24.140 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 6276K, 20% free 25908K/32356K, paused 2ms+1ms, total 18ms
07-29 05:43:24.140 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 8ms
07-29 05:43:24.344 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 6581K, 20% free 27114K/33872K, paused 1ms+1ms, total 22ms
07-29 05:43:24.344 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 12ms
07-29 05:43:24.588 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 6847K, 20% free 28632K/35364K, paused 2ms+0ms, total 25ms
07-29 05:43:25.100 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 7586K, 21% free 29210K/36924K, paused 1ms+1ms, total 32ms
07-29 05:43:25.844 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 155 bytes, free space 12 bytes, window size 2097152 bytes
07-29 05:43:26.172 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 20259K, 53% free 17639K/37472K, paused 2ms+0ms, total 25ms
07-29 05:43:26.216 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 744 bytes, free space 499 bytes, window size 2097152 bytes
07-29 05:43:26.272 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1198 bytes, free space 2 bytes, window size 2097152 bytes
07-29 05:43:26.280 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 73K, 40% free 22517K/37472K, paused 1ms+0ms, total 8ms
07-29 05:43:26.340 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 110 bytes, free space 53 bytes, window size 2097152 bytes
07-29 05:43:26.400 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 642 bytes, free space 431 bytes, window size 2097152 bytes
07-29 05:43:26.424 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 47K, 23% free 29148K/37472K, paused 1ms+0ms, total 11ms
07-29 05:43:26.476 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 36 bytes, free space 35 bytes, window size 2097152 bytes
07-29 05:43:26.552 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1238 bytes, free space 380 bytes, window size 2097152 bytes
07-29 05:43:26.652 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 295 bytes, free space 170 bytes, window size 2097152 bytes
07-29 05:43:26.680 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 172K, 1% free 37165K/37472K, paused 2ms+1ms, total 22ms
07-29 05:43:26.680 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 11ms
07-29 05:43:26.768 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1833 bytes, free space 1392 bytes, window size 2097152 bytes
07-29 05:43:26.860 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 737 bytes, free space 171 bytes, window size 2097152 bytes
07-29 05:43:26.940 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 1K, 1% free 45285K/45416K, paused 2ms+1ms, total 23ms
07-29 05:43:26.980 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 905 bytes, free space 85 bytes, window size 2097152 bytes
07-29 05:43:27.108 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 370 bytes, free space 281 bytes, window size 2097152 bytes
07-29 05:43:27.240 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1146 bytes, free space 60 bytes, window size 2097152 bytes
07-29 05:43:27.456 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 155K, 1% free 53325K/53608K, paused 2ms+1ms, total 49ms
07-29 05:43:27.456 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 27ms
07-29 05:43:27.576 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1000 bytes, free space 551 bytes, window size 2097152 bytes
07-29 05:43:27.720 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 547 bytes, free space 383 bytes, window size 2097152 bytes
07-29 05:43:27.836 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1028 bytes, free space 326 bytes, window size 2097152 bytes
07-29 05:43:27.904 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 1K, 1% free 61512K/61644K, paused 2ms+1ms, total 35ms
07-29 05:43:27.904 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 26ms
07-29 05:43:28.000 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1 079 bytes, free space 663 bytes, window size 2097152 bytes
07-29 05:43:28.136 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 628 bytes, free space 539 bytes, window size 2097152 bytes
07-29 05:43:28.264 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 352 bytes, free space 257 bytes, window size 2097152 bytes
07-29 05:43:28.308 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 230K, 1% free 69472K/69832K, paused 1ms+2ms, total 24ms
07-29 05:43:28.308 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 15ms
07-29 05:43:28.404 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 8 bytes, free space 0 bytes, window size 2097152 bytes
07-29 05:43:28.552 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 612 bytes, free space 246 bytes, window size 2097152 bytes
07-29 05:43:28.680 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1180 bytes, free space 629 bytes, window size 2097152 bytes
07-29 05:43:28.736 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed <1K, 1% free 77663K/77792K, paused 2ms+1ms, total 41ms
07-29 05:43:28.736 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 30ms
07-29 05:43:28.884 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 15 bytes, free space 0 bytes, window size 2097152 bytes
07-29 05:43:29.032 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 261 bytes, free space 41 bytes, window size 2097152 bytes
07-29 05:43:29.204 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1631 bytes, free space 224 bytes, window size 2097152 bytes
07-29 05:43:29.244 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed <1K, 1% free 85851K/85980K, paused 2ms+1ms, total 32ms
07-29 05:43:29.244 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 19ms
07-29 05:43:29.396 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 1081 bytes, free space 77 bytes, window size 2097152 bytes
07-29 05:43:29.536 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 983 bytes, free space 724 bytes, window size 2097152 bytes
07-29 05:43:29.620 3308-3312/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 99.625MB to 96.000MB
07-29 05:43:29.620 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed 344K, 1% free 93698K/94172K, paused 3ms+2ms, total 34ms
07-29 05:43:29.620 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 25ms
07-29 05:43:29.744 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 235 bytes, free space 174 bytes, window size 2097152 bytes
07-29 05:43:29.900 3308-3308/com.example.sharecorn.wordydictionary W/CursorWindow: Window is full: requested allocation 2302 bytes, free space 2044 bytes, window size 2097152 bytes
07-29 05:43:29.956 3308-3312/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 103.995MB to 96.000MB
07-29 05:43:29.956 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed <1K, 1% free 98172K/98304K, paused 2ms+1ms, total 34ms
07-29 05:43:29.960 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 26ms
07-29 05:43:29.960 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Forcing collection of SoftReferences for 3146-byte allocation
07-29 05:43:30.016 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 103.987MB to 96.000MB
07-29 05:43:30.016 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: GC_BEFORE_OOM freed 10K, 1% free 98162K/98304K, paused 59ms, total 59ms
07-29 05:43:30.064 3308-3312/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 103.998MB to 96.000MB
07-29 05:43:30.068 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed <1K, 1% free 98173K/98304K, paused 2ms+2ms, total 47ms
07-29 05:43:30.068 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 32ms
07-29 05:43:30.068 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Forcing collection of SoftReferences for 1160-byte allocation
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 103.998MB to 96.000MB
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: GC_BEFORE_OOM freed <1K, 1% free 98172K/98304K, paused 47ms, total 47ms
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary E/dalvikvm-heap: Out of memory on a 1160-byte allocation.
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0xa6225938 self=0xb7fc08e8
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: | sysTid=3308 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-1216368480
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: | state=R schedstat=( 7006311432 1406884302 2716 ) utm=621 stm=78 core=0
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.database.CursorWindow.nativeGetString(Native Method)
07-29 05:43:30.112 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.database.CursorWindow.getString(CursorWindow.java:434)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at com.example.sharecorn.wordydictionary.DictionaryDatabaseHelper.getAllWords(DictionaryDatabaseHelper.java:90)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at com.example.sharecorn.wordydictionary.Dictionary_list.onCreate(Dictionary_list.java:65)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.Activity.performCreate(Activity.java:5104)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.os.Looper.loop(Looper.java:137)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at android.app.ActivityThread.main(ActivityThread.java:5041)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at java.lang.reflect.Method.invokeNative(Native Method)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at java.lang.reflect.Method.invoke(Method.java:511)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-29 05:43:30.116 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm: at dalvik.system.NativeStart.main(Native Method)
07-29 05:43:30.148 3308-3312/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Clamp target GC heap from 103.998MB to 96.000MB
07-29 05:43:30.148 3308-3312/com.example.sharecorn.wordydictionary D/dalvikvm: GC_CONCURRENT freed <1K, 1% free 98173K/98304K, paused 3ms+1ms, total 33ms
07-29 05:43:30.148 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 26ms
07-29 05:43:30.148 3308-3308/com.example.sharecorn.wordydictionary I/dalvikvm-heap: Forcing collection of SoftReferences for 184-byte allocation
07-29 05:43:30.188 3308-3308/com.example.sharecorn.wordydictionary D/dalvikvm: GC_BEFORE_OOM freed 82975K, 84% free 15197K/94240K, paused 40ms, total 40ms
07-29 05:43:30.192 3308-3308/com.example.sharecorn.wordydictionary D/AndroidRuntime: Shutting down VM
07-29 05:43:30.192 3308-3308/com.example.sharecorn.wordydictionary W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa6224908)
07-29 05:43:30.192 3308-3308/com.example.sharecorn.wordydictionary E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.database.CursorWindow.nativeGetString(Native Method)
at android.database.CursorWindow.getString(CursorWindow.java:434)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at com.example.sharecorn.wordydictionary.DictionaryDatabaseHelper.getAllWords(DictionaryDatabaseHelper.java:90)
at com.example.sharecorn.wordydictionary.Dictionary_list.onCreate(Dictionary_list.java:65)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
我是SQLite的新手。我正在使用SQLite数据库开发一个字典应用程序。我使用的是包含所有单词的字典文件,大小接近5MB。 当我在虚拟机中运行应用程序时,我收到上述错误。 这是我的DatabaseHelper类
public class DictionaryDatabaseHelper extends SQLiteOpenHelper{
final static String ITEM_ID_COLUMN = "id";
final static String WORD_COLUMN = "word";
final static String DEFINATION_COLUMN = "defination";
final static String DICTIONARY_DATABASE = "dictionary";//name of our database
final static String CREATE_DATABASE_QUERY="CREATE TABLE "+DICTIONARY_DATABASE+" ( "+
ITEM_ID_COLUMN+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
WORD_COLUMN+" TEXT , "+
DEFINATION_COLUMN+" TEXT)";
//command for upgrading database(delete)
final static String ON_UPGRADE_QUERY = "DROP TABLE"+DICTIONARY_DATABASE;
Context context;
public DictionaryDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DICTIONARY_DATABASE, factory, version);
this.context = context;
}
@Override
public void onCreate(SQLiteDatabase database) {
database.execSQL(CREATE_DATABASE_QUERY);//create the databse
}
@Override
//if we upgrade the database
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
database.execSQL(ON_UPGRADE_QUERY);
onCreate(database);
}
public long insertData(WordDefination wordDefination){
SQLiteDatabase database = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(WORD_COLUMN,wordDefination.word); values.put(DEFINATION_COLUMN,wordDefination.defination);
return database.insert(DICTIONARY_DATABASE,null,values);
}
public long updteData(WordDefination wordDefination){
SQLiteDatabase database = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(WORD_COLUMN,wordDefination.word);
values.put(DEFINATION_COLUMN,wordDefination.defination);
return database.update(DICTIONARY_DATABASE,values,WORD_COLUMN+"=?",new String[]{wordDefination.word});//jodi wordDefination.word mile jay tobe amra update korte chai
}
public void deleteData(WordDefination wordDefination){
SQLiteDatabase database = this.getWritableDatabase();
String queryString = "DELETE FROM"+DICTIONARY_DATABASE+"WHERE "+WORD_COLUMN+"='"+wordDefination.word+"'";//deleting from the word column (sigle quotation must)
database.execSQL(queryString);
}
public ArrayList<WordDefination> getAllWords(){
ArrayList<WordDefination> arrayList = new ArrayList<WordDefination>();
SQLiteDatabase database = this.getReadableDatabase();
String selectAllQueryString = "SELECT * FROM "+DICTIONARY_DATABASE;//SELECT EVERYTHING FROM DICTIONARY DATABASE
Cursor cursor = database.rawQuery(selectAllQueryString,null);
if(cursor.moveToFirst()){
do{
WordDefination wordDefination = new WordDefination(cursor.getString(cursor.getColumnIndex(WORD_COLUMN)),cursor.getString(cursor.getColumnIndex(DEFINATION_COLUMN)));//object of arraylist with word and defination
arrayList.add(wordDefination);
}while (cursor.moveToNext());//loop untill next element is present
}
return arrayList;
}
//search word defination by word
public WordDefination getWordDefination(String word) {
SQLiteDatabase database = this.getReadableDatabase();
WordDefination wordDefination = null;//if nothing found
String selectQueryString="SELECT * FROM "+DICTIONARY_DATABASE+ " WHERE "+WORD_COLUMN+" = '"+word+ "'";
Cursor cursor = database.rawQuery(selectQueryString, null);
if (cursor.moveToFirst()) {//moving the cursor to first
wordDefination = new WordDefination(cursor.getString(cursor.getColumnIndex(WORD_COLUMN)), cursor.getString(cursor.getColumnIndex(DEFINATION_COLUMN)));//object of arraylist with word and defination
}
return wordDefination;
}
//Search word definition by id
public WordDefination getWordDefination(long id) {
SQLiteDatabase database = this.getReadableDatabase();
WordDefination wordDefination = null;//if nothing found
String selectQueryString = "SELECT * FROM" + DICTIONARY_DATABASE + "WHERE" + ITEM_ID_COLUMN + "= '" + id + "'";
Cursor cursor = database.rawQuery(selectQueryString, null);
if (cursor.moveToFirst()) {//moving the cursor to first
wordDefination = new WordDefination(cursor.getString(cursor.getColumnIndex(WORD_COLUMN)), cursor.getString(cursor.getColumnIndex(DEFINATION_COLUMN)));//object of arraylist with word and defination
}
return wordDefination;
}
//to minimize the transaction time we initialize the whole database at one time
public void initializeDatabaseForFirstTime(ArrayList<WordDefination> wordDefinations){
SQLiteDatabase database = this.getWritableDatabase();
database.execSQL("BEGIN");
ContentValues contentValues = new ContentValues();
for(WordDefination wordDefination : wordDefinations){
contentValues.put(WORD_COLUMN,wordDefination.word);
contentValues.put(DEFINATION_COLUMN,wordDefination.defination);
database.insert(DICTIONARY_DATABASE,null,contentValues);
}
database.execSQL("COMMIT");
}
}
我想知道为什么我会得到例外?字典文件的大小是否导致异常或其他?什么是解决方案?
答案 0 :(得分:0)
我发现您没有关闭方法config/orientdb-server-config.xml
和 <handler class="com.orientechnologies.orient.server.handler.OJMXPlugin">
<parameters>
</parameters>
</handler>
中的Cursor
。所以,我想知道你是怎么称呼这种方法的?有多少次?
此外,ArrayList<WordDefination> getAllWords()
的设计很糟糕,因为您的数据库很大。
答案 1 :(得分:0)
第一个光标有问题,你没有关闭。
更多关于在代码中避免静态,如果非常必要,那么你应该使用它。它也给我们带来内存不足的问题。 您可以在这里查看更多详细信息,了解我们如何在Android应用中优化内存。 这是link
希望这会对你有所帮助。