Android应用力附加SQL精简版codeS后关闭 [英] Android application force closes after adding SQL Lite codes

查看:183
本文介绍了Android应用力附加SQL精简版codeS后关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与SQL精简版为我的手机型号一个问题,就是LG的Optimus One P500。我的手机Android版本从升级Froyo更新到姜饼和更新工作正常,在我身上。我的应用程序也适用于其他手机型号的罚款。

I'm having a problem with the SQL Lite for my phone model is LG Optimus One P500. my phone android version is updated from FroYo to Gingerbread and update works fine on me. My app also works fine on other phone models.

应用程序工作在第一,也说明我的主网页,但是当我开始游戏的问题,那么出现再发力关闭我的应用程序。

Application works at first and also shows my main page but when I start the game the problem then appears and then force closes my app.

数据库创建(初始化)活动比分页之后开始显示,所以我想以后我开始游戏不应该存在问题,但毕竟这个问题,只有当我说我的数据库codeS开始的。

Database creation (initialization) activity begins after the score page will show so I think the problem should not exists after I start the game but after all this problem only started when I added my database codes.

为了更好地理解我的行为是这样的:

For better understanding my activity goes like this:


  1. 在启动时获取名称,然后在一个字符串变量存储名称
    启动按钮后pressed。 (我的问题存在,那么这个部分)

  2. 我有一个计时器,并在我的第二个进球布局文字游戏结束后,这将在以后获取。

  3. 该数据库将现在被创建(如果尚未存在),然后将这些3的数据将被存储在数据库中。

下面是我的数据库code(我只是从一个教程得到它从Web):

Here's my database code (I just get it from a tutorial from the web):

public class DataHelper {

    private static final String DATABASE_NAME = "scores.db";
       private static final int DATABASE_VERSION = 1;
       private static final String TABLE_NAME = "tblScores";

       private Context context;
       private SQLiteDatabase db;

       private SQLiteStatement insertStmt;
       private static final String INSERT = "insert into "
          + TABLE_NAME + "(name,score,time) values (?,?,?)";

       public DataHelper(Context context) {
              this.context = context;
              OpenHelper openHelper = new OpenHelper(this.context);
              this.db = openHelper.getWritableDatabase();
              this.insertStmt = this.db.compileStatement(INSERT);
           }

       public long insert(String name, String score, String time) {
          this.insertStmt.bindString(1, name);
          this.insertStmt.bindString(2, score); 
          this.insertStmt.bindString(3, time);
          return this.insertStmt.executeInsert();
       }

       public void deleteAll() {
          this.db.delete(TABLE_NAME, null, null);
       }

       public List<String> selectAll() {
              List<String> list = new ArrayList<String>();
              Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name","score","time" },
                /*"name in ('A','B')"*/ null, null, /*"name"*/null, null, "score, time desc");
              if (cursor.moveToFirst()) {
                 do {
                    list.add(cursor.getString(0)+" "+cursor.getString(1)+" "+cursor.getString(2));
                    //list.add(cursor.getString(1));
                 } while (cursor.moveToNext());
              }
              if (cursor != null && !cursor.isClosed()) {
                 cursor.close();
              }
              return list;
           }

       private static class OpenHelper extends SQLiteOpenHelper {

          OpenHelper(Context context) {
             super(context, DATABASE_NAME, null, DATABASE_VERSION);
          }

          @Override
          public void onCreate(SQLiteDatabase db) {
             db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name TEXT, score TEXT, time TEXT)");
          }

          @Override
          public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
             Log.w("Example", "Upgrading database, this will drop tables and recreate.");
             db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
             onCreate(db);
          }
       }
    }

下面是从我的手机日志文件:

Here's the log file from my phone:

[android.intent.category.LAUNCHER] flg=0x10200000 cmp=arc.android.memorygame/.Ma
inActivity } from pid 1875
D/PhoneWindow( 1875): <!>com.android.internal.policy.impl.PhoneWindow 1472<!> co
uldn't save which view has focus because the focused view com.jiubang.ggheart.ap
ps.desks.appfunc.XViewFrame@40675e08 has no id.
I/ActivityManager( 1573): Start proc arc.android.memorygame for activity arc.and
roid.memorygame/.MainActivity: pid=12927 uid=10098 gids={1015}
I/ggheart ( 1875): <!>fs 742<!> onStop
I/wpa_supplicant( 1731): wpa_supplicant_get_scan_results: Start
I/wpa_supplicant( 1731): CTRL-EVENT-SCAN-RESULTS  Ready
I/wpa_supplicant( 1731): wpa_supplicant_event_scan_results: ap_scan 1,  disconne
cted 0
I/wpa_supplicant( 1731): No suitable AP found.
I/wpa_supplicant( 1731): Setting scan request: 20 sec 0 usec
I/dun_service( 1481): process rmnet event
I/dun_service( 1481):  rstate == DUN_RMNETSTATE_ERROR in dun_monitor_kevents
V/WifiMonitor( 1573): <!>android.net.wifi.WifiMonitor$MonitorThread 176<!> Event
 [Setting scan request: 20 sec 0 usec]
I/#LGIME  ( 1671): <!>com.jungle.android.utils.Glog 32<!> #### onStartInput: res
tarting=false, fieldId=2131099699
I/ActivityManager( 1573): <!>com.android.server.am.ActivityRecord 444<!> Display
ed arc.android.memorygame/.MainActivity: +1s490ms
D/StatusBarPolicy( 1657): [BRIGHTHY] 0. mDataNetType: 1
D/StatusBarPolicy( 1657): [BRIGHTHY] curNetwork=51502 curHPLMN=51502
E/dalvikvm-heap(12927): 9850880-byte external allocation too large for this proc
ess.
E/GraphicsJNI(12927): VM won't let us allocate 9850880 bytes
D/skia    (12927): --- decoder->decode returned false
W/dalvikvm(12927): threadid=1: thread exiting with uncaught exception (group=0x4
0018560)
E/AndroidRuntime(12927): FATAL EXCEPTION: main
E/AndroidRuntime(12927): android.view.InflateException: Binary XML file line #2:
 Error inflating class <unknown>
E/AndroidRuntime(12927):        at android.view.LayoutInflater.createView(Layout
Inflater.java:518)
E/AndroidRuntime(12927):        at com.android.internal.policy.impl.PhoneLayoutI
nflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime(12927):        at android.view.LayoutInflater.createViewFromTag
(LayoutInflater.java:568)
E/AndroidRuntime(12927):        at android.view.LayoutInflater.inflate(LayoutInf
later.java:386)
E/AndroidRuntime(12927):        at android.view.LayoutInflater.inflate(LayoutInf
later.java:320)
E/AndroidRuntime(12927):        at android.view.LayoutInflater.inflate(LayoutInf
later.java:276)
E/AndroidRuntime(12927):        at com.android.internal.policy.impl.PhoneWindow.
setContentView(PhoneWindow.java:207)
E/AndroidRuntime(12927):        at android.app.Activity.setContentView(Activity.
java:1657)
E/AndroidRuntime(12927):        at arc.android.memorygame.MainActivity.startGame
(MainActivity.java:194)
E/AndroidRuntime(12927):        at arc.android.memorygame.MainActivity$1.onClick
(MainActivity.java:108)
E/AndroidRuntime(12927):        at android.view.View.performClick(View.java:2485
)
E/AndroidRuntime(12927):        at android.view.View$PerformClick.run(View.java:
9080)
E/AndroidRuntime(12927):        at android.os.Handler.handleCallback(Handler.jav
a:587)
E/AndroidRuntime(12927):        at android.os.Handler.dispatchMessage(Handler.ja
va:92)
E/AndroidRuntime(12927):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(12927):        at android.app.ActivityThread.main(ActivityThrea
d.java:3729)
E/AndroidRuntime(12927):        at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(12927):        at java.lang.reflect.Method.invoke(Method.java:5
07)
E/AndroidRuntime(12927):        at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:874)
E/AndroidRuntime(12927):        at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:632)
E/AndroidRuntime(12927):        at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(12927): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime(12927):        at java.lang.reflect.Constructor.constructNative
(Native Method)
E/AndroidRuntime(12927):        at java.lang.reflect.Constructor.newInstance(Con
structor.java:415)
E/AndroidRuntime(12927):        at android.view.LayoutInflater.createView(Layout
Inflater.java:505)
E/AndroidRuntime(12927):        ... 20 more
E/AndroidRuntime(12927): Caused by: java.lang.OutOfMemoryError: bitmap size exce
eds VM budget
E/AndroidRuntime(12927):        at android.graphics.BitmapFactory.nativeDecodeAs
set(Native Method)
E/AndroidRuntime(12927):        at android.graphics.BitmapFactory.decodeStream(B
itmapFactory.java:460)
E/AndroidRuntime(12927):        at android.graphics.BitmapFactory.decodeResource
Stream(BitmapFactory.java:336)
E/AndroidRuntime(12927):        at android.graphics.drawable.Drawable.createFrom
ResourceStream(Drawable.java:697)
E/AndroidRuntime(12927):        at android.content.res.Resources.loadDrawable(Re
sources.java:1709)
E/AndroidRuntime(12927):        at android.content.res.TypedArray.getDrawable(Ty
pedArray.java:601)
E/AndroidRuntime(12927):        at android.view.View.<init>(View.java:1951)
E/AndroidRuntime(12927):        at android.view.View.<init>(View.java:1899)
E/AndroidRuntime(12927):        at android.view.ViewGroup.<init>(ViewGroup.java:
286)
E/AndroidRuntime(12927):        at android.widget.LinearLayout.<init>(LinearLayo
ut.java:120)
E/AndroidRuntime(12927):        ... 23 more
W/ActivityManager( 1573):   Force finishing activity arc.android.memorygame/.Mai
nActivity
W/ActivityManager( 1573): Activity pause timeout for HistoryRecord{4070d4e8 arc.
android.memorygame/.MainActivity}
I/DemoService( 1875): <!>fs 730<!> DiyScheduer.onStart
I/ggheart ( 1875): <!>fs 732<!> onStart
I/ActivityManager( 1573): No longer want com.viber.voip:keepAliveReceiver (pid 2
474): hidden #16
D/StatusBarPolicy( 1657): [BRIGHTHY] 0. mDataNetType: 1
D/StatusBarPolicy( 1657): [BRIGHTHY] curNetwork=51502 curHPLMN=51502
I/#LGIME  ( 1671): <!>com.jungle.android.utils.Glog 32<!> #### onStartInput: res
tarting=false, fieldId=-1
I/ActivityManager( 1573): Process arc.android.memorygame (pid 12927) has died.

此外,任何人都可以帮助我在Java中查询?我在这一个相当新手。正如你看到的,我只需要编辑,然后测试查询命令。这是如何工作的详细视图将被罚款。

Also, anyone can help me in querying in Java? I'm quite a newbie in this one. As you see I'm just editing then testing the query commands. A detailed view on how this works will be fine.

推荐答案

嘛。例外是在那里 - OutOfMemoryError错误而膨胀的位图

Well. the exception is in there - OutOfMemoryError while inflating a bitmap

这篇关于Android应用力附加SQL精简版codeS后关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆