I have this code:
String sql="UPDATE LAST_OPEN SET LAST_OPEN="+DATE+" WHERE STUDENT_ID ="+STUDENT_ID+" AND ITEM_ID="+ITEM_ID+" AND ITEM_NAME="+ITEM_TYPE+";";
db.execSQL(sql);
Where LAST_OPEN field is timestamp.I tried to run the same query in SQlite Browser it was working fine.But when this Sql is executed in app it shows this:
02-13 13:12:39.468: E/AndroidRuntime(2366): FATAL EXCEPTION: main
02-13 13:12:39.468: E/AndroidRuntime(2366): android.database.sqlite.SQLiteException: near "13": syntax error: UPDATE LAST_OPEN SET LAST_OPEN=2012-02-13 13:12:39 WHERE STUDENT_ID =5 AND ITEM_ID=1 AND ITEM_NAME=Activity;
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
-13 13:12:39.468: E/AndroidRuntime(2366): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727)
02-13 13:12:39.468: E/AndroidRuntime(2366): at com.cuelearn.databases.last_open.update(last_open.java:205)
02-13 13:12:39.468: E/AndroidRuntime(2366): at com.cuelearn.main.threeshelf$1.onClick(threeshelf.java:197)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.view.View.performClick(View.java:2408)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.view.View$PerformClick.run(View.java:8816)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.os.Handler.handleCallback(Handler.java:587)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.os.Handler.dispatchMessage(Handler.java:92)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.os.Looper.loop(Looper.java:123)
02-13 13:12:39.468: E/AndroidRuntime(2366): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-13 13:12:39.468: E/AndroidRuntime(2366): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 13:12:39.468: E/AndroidRuntime(2366): at java.lang.reflect.Method.invoke(Method.java:521)
02-13 13:12:39.468: E/AndroidRuntime(2366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-13 13:12:39.468: E/AndroidRuntime(2366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
Can anyone tell where I am getting wrong?
Try with this sql statement :
String sql="UPDATE LAST_OPEN SET LAST_OPEN='"+DATE+"' WHERE STUDENT_ID ="+STUDENT_ID+" AND ITEM_ID="+ITEM_ID+" AND ITEM_NAME="+ITEM_TYPE+";";
as I know, when you are using any string data in sql statement you need to add '' in the beginning of the variable and at the end of it.
Try to change
LAST_OPEN=2012-02-13 13:12:39
with
LAST_OPEN = "2012-02-13 13:12:39"
The space between the numbers can be the problem. Hope this helps.
Related
I am getting this error in my android app. When I am going for auto suggestion, I got this error. Why I am getting this error. Please Help me.
FATAL EXCEPTION: main
java.lang.NumberFormatException: Invalid long: "name"
at java.lang.Long.invalidLong(Long.java:125)
at java.lang.Long.parse(Long.java:362)
at java.lang.Long.parseLong(Long.java:353)
at java.lang.Long.parseLong(Long.java:319)
at android.database.MatrixCursor.getLong(MatrixCursor.java:255)
at android.widget.CursorAdapter.getItemId(CursorAdapter.java:220)
at android.widget.AutoCompleteTextView.buildImeCompletions(AutoCompleteTextView.java:1123)
at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1082)
at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:971)
at android.widget.AutoCompleteTextView.access$800(AutoCompleteTextView.java:91)
at android.widget.AutoCompleteTextView$PopupDataSetObserver$1.run(AutoCompleteTextView.java:1268)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5299)
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:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
This will crash since it isn't a long
Long.parseLong("name")
It has to be something like this
Long.parseLong("12345567890")
I have a game in Google Play. It have been working fine in the previous 3 updates. But in the 4th after you download and install the update the game crashes only in Android 4.1.1 devices.
It happens because somehow GooglePlay installed incorrectly the application and the native library is not correctly set up.
Reading some Google forms I believe this is know problem of that android firmware. I already worked around that by saving the native library in the res files and coping it to /data/data/com.minix.android.Game/files and loading it from there. Yet the players lost all of their progress, like if the corrupt installation clears the game data.
02-28 15:40:49.050: W/dalvikvm(23159): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/minix/android/Game;
02-28 15:40:49.050: W/dalvikvm(23159): Class init failed in newInstance call (Lcom/minix/android/Game;)
02-28 15:40:49.050: D/AndroidRuntime(23159): Shutting down VM
02-28 15:40:49.050: W/dalvikvm(23159): threadid=1: thread exiting with uncaught exception (group=0x410382a0)
02-28 15:40:49.050: D/KeyguardViewMediator(2465): setHidden false
02-28 15:40:49.050: D/WindowManager(2465): mInputFocus is not null.
02-28 15:40:49.050: D/WindowManager(2465): mInputFocus is not null.
02-28 15:40:49.050: E/AndroidRuntime(23159): FATAL EXCEPTION: main
02-28 15:40:49.050: E/AndroidRuntime(23159): java.lang.ExceptionInInitializerError
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.Class.newInstanceImpl(Native Method)
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.Class.newInstance(Class.java:1319)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.os.Looper.loop(Looper.java:137)
02-28 15:40:49.050: E/AndroidRuntime(23159): at android.app.ActivityThread.main(ActivityThread.java:4898)
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.reflect.Method.invokeNative(Native Method)
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.reflect.Method.invoke(Method.java:511)
02-28 15:40:49.050: E/AndroidRuntime(23159): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
02-28 15:40:49.050: E/AndroidRuntime(23159): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
02-28 15:40:49.050: E/AndroidRuntime(23159): at dalvik.system.NativeStart.main(Native Method)
02-28 15:40:49.050: E/AndroidRuntime(23159): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load minix: findLibrary returned null
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.Runtime.loadLibrary(Runtime.java:365)
02-28 15:40:49.050: E/AndroidRuntime(23159): at java.lang.System.loadLibrary(System.java:535)
02-28 15:40:49.050: E/AndroidRuntime(23159): at com.minix.android.Game.GameActivity <clinit>(Unknown Source)
02-28 15:40:49.050: E/AndroidRuntime(23159): ... 15 more
Several reasons that might cause this:
You don't have this in your code:
static {
System.loadLibrary("mylibraryname");
}
You changed your package name in the code or in the package itself and they don't match.
You use an expired or invalid signature to sign your app.
I'm trying to use some emulators to run my apps for debugging. This app runs perfectly on my phone, but when I load it up into the emulator it crashes whenever I invoke an opencv function. The emulator is using the intel atom x86 cpu. Do I have to run them with the arm7?
Stack trace:
02-13 04:25:51.986: E/AndroidRuntime(2006): FATAL EXCEPTION: main
02-13 04:25:51.986: E/AndroidRuntime(2006): java.lang.ExceptionInInitializerError
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.uas.Processor.extract(Processor.java:48)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.uas.ImageProcessorActivity.onMenuItemClick(ImageProcessorActivity.java:626)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.widget.PopupMenu.onMenuItemSelected(PopupMenu.java:142)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.view.menu.MenuPopupHelper.onItemClick(MenuPopupHelper.java:156)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.widget.AdapterView.performItemClick(AdapterView.java:298)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.widget.AbsListView$1.run(AbsListView.java:3423)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.os.Handler.handleCallback(Handler.java:725)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.os.Handler.dispatchMessage(Handler.java:92)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.os.Looper.loop(Looper.java:137)
02-13 04:25:51.986: E/AndroidRuntime(2006): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-13 04:25:51.986: E/AndroidRuntime(2006): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 04:25:51.986: E/AndroidRuntime(2006): at java.lang.reflect.Method.invoke(Method.java:511)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-13 04:25:51.986: E/AndroidRuntime(2006): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-13 04:25:51.986: E/AndroidRuntime(2006): at dalvik.system.NativeStart.main(Native Method)
02-13 04:25:51.986: E/AndroidRuntime(2006): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_java from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.uas-1.apk,libraryPath=/data/app-lib/com.uas-1]: findLibrary returned null
02-13 04:25:51.986: E/AndroidRuntime(2006): at java.lang.Runtime.loadLibrary(Runtime.java:365)
02-13 04:25:51.986: E/AndroidRuntime(2006): at java.lang.System.loadLibrary(System.java:535)
02-13 04:25:51.986: E/AndroidRuntime(2006): at org.opencv.core.Mat.<clinit>(Mat.java:2065)
02-13 04:25:51.986: E/AndroidRuntime(2006): ... 20 more
I want to get the String from an EditText and then read individual characters from it. I've tried the following code:
String PT = pt.getText().toString();
int len = PT.length();
char chars[] = PT.toCharArray();
for(int i=0;i<len;i++)
{ Toast.makeText(encrypt.this,chars[i], 0).show(); }
However I get a Force Close error on this. Where am I going wrong?
I'm quite new to all this!
Here's the LogCat:
11-28 12:41:01.228: E/AndroidRuntime(1632): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-28 12:41:01.228: E/AndroidRuntime(1632): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 12:41:01.228: E/AndroidRuntime(1632): at java.lang.reflect.Method.invoke(Method.java:507)
11-28 12:41:01.228: E/AndroidRuntime(1632): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-28 12:41:01.228: E/AndroidRuntime(1632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-28 12:41:01.228: E/AndroidRuntime(1632): at dalvik.system.NativeStart.main(Native Method)
11-28 12:46:43.688: W/KeyCharacterMap(1674): No keyboard for id 0
11-28 12:46:43.688: W/KeyCharacterMap(1674): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-28 12:46:54.442: W/ResourceType(1674): No package identifier when getting value for resource number 0x00000061
11-28 12:46:54.448: D/AndroidRuntime(1674): Shutting down VM
11-28 12:46:54.448: W/dalvikvm(1674): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-28 12:46:54.459: E/AndroidRuntime(1674): FATAL EXCEPTION: main
11-28 12:46:54.459: E/AndroidRuntime(1674): android.content.res.Resources$NotFoundException: String resource ID #0x61
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.content.res.Resources.getText(Resources.java:201)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.widget.Toast.makeText(Toast.java:258)
11-28 12:46:54.459: E/AndroidRuntime(1674): at com.project.DENCrypt.encrypt$1.onClick(encrypt.java:33)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.view.View.performClick(View.java:2485)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.view.View$PerformClick.run(View.java:9080)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.os.Handler.handleCallback(Handler.java:587)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.os.Handler.dispatchMessage(Handler.java:92)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.os.Looper.loop(Looper.java:123)
11-28 12:46:54.459: E/AndroidRuntime(1674): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-28 12:46:54.459: E/AndroidRuntime(1674): at java.lang.reflect.Method.invokeNative(Native Method)
11-28 12:46:54.459: E/AndroidRuntime(1674): at java.lang.reflect.Method.invoke(Method.java:507)
11-28 12:46:54.459: E/AndroidRuntime(1674): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-28 12:46:54.459: E/AndroidRuntime(1674): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-28 12:46:54.459: E/AndroidRuntime(1674): at dalvik.system.NativeStart.main(Native Method)
Toast.makeText(encrypt.this,String.valueOf(chars[i]), 0).show();
instead of
Toast.makeText(encrypt.this,chars[i], 0).show();
try this:
Toast.makeText(encrypt.this,chars[i] + "", 0).show();
it has the same way with Ram's
Change your toast message to
Toast.makeText(encrypt.this,Character.toString(chars[i]), Toast.LENGTH_SHORT).show();
Here the problem is with Toast message. Toast can not Display charaters. so convert charater to string and display
the chars[i] is integer value. If you look closely in your error log you will see
android.content.res.Resources$NotFoundException: String resource ID #0x61
(if you pass integer parameter, android will lookup for a resource with this Id)
you can print the character from the string directly:
Toast.makeText(encrypt.this,PT[i], 0).show();
probably the edit text (layout resource)is not available when reading the data from it. Just check whether you are able to get no null value when you do
EditText edt1 = (EditText)findViewById(R.id.myEditView);
log edt1(either through log, system.out.println);
I want to create a feedback field for my application. I just want redirect the user to the market like this
String APP_MARKET_URL = "market://details?id=com.my.application";
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse(APP_MARKET_URL));
this.startActivity(intent);
But when i execute it i have this error:
02-13 11:07:33.147: W/dalvikvm(238): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
02-13 11:07:33.155: E/AndroidRuntime(238): Uncaught handler: thread main exiting due to uncaught exception
02-13 11:07:33.225: E/AndroidRuntime(238): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.picca.pointage.NoterApplication }
02-13 11:07:33.225: E/AndroidRuntime(238): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.app.Activity.startActivityForResult(Activity.java:2749)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.app.Activity.startActivity(Activity.java:2855)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.preference.Preference.performClick(Preference.java:829)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.preference.PreferenceScreen.onItemClick(PreferenceScreen.java:190)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.widget.ListView.performItemClick(ListView.java:3285)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.os.Handler.handleCallback(Handler.java:587)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.os.Handler.dispatchMessage(Handler.java:92)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.os.Looper.loop(Looper.java:123)
02-13 11:07:33.225: E/AndroidRuntime(238): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-13 11:07:33.225: E/AndroidRuntime(238): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 11:07:33.225: E/AndroidRuntime(238): at java.lang.reflect.Method.invoke(Method.java:521)
02-13 11:07:33.225: E/AndroidRuntime(238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-13 11:07:33.225: E/AndroidRuntime(238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-13 11:07:33.225: E/AndroidRuntime(238): at dalvik.system.NativeStart.main(Native Method)
I use android 1.5. I did not put specific entry in the manifest.
Anyone have an idea or an other method for call my market page?
Expanding on a previous comment, you can check if the Intent can be resolved on the device before starting a new Activity with it using code like this:
PackageManager pm = context.getPackageManager();
ComponentName cn = intent.resolveActivity(pm);
if (cn != null) {
this.startActivity(intent);
}
Try adding the following flat to your intent.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
If you're running this code on the emulator, you should know that there is no Android Market application on the emulator, so it will throw you this exception. There should be no problem on most of the real devices. Hope this helps.