|
Hello all,
I have made a dictionary app that communicates with a database in a server using a webservice. Now my boss wants me to embed the database inside the app so that offline users can also use the dictionary.
Can you give me some advices on how to do that?
How can I add whole database inside an app?
Should I create an XML for each database table?
Is SQLite an option?
I'm open to any advices and suggestions.
Thanks in advance.
|
|
|
|
|
Psst, ditch your idiot boss! Why in the very first place did he need to create an entire server for web services to allow such functionality that in the end he had to download the entire server (in my mind it would be of 900+ MB) to the application.
Ok, lets for a second consider that the application is downloaded and the content is also available. What makes you so sure that the client would have 1GB extra just for your application, most Android devices do not have more than 500 MB of HDD space. In such cases you must use web services. Offline? Which Android device is offline now adays. My (3) Android devices are connected to Internet and when WiFi is not present one of them provides tethering services to the two of the devices.
In the end, if your boss really does want to do this, here is the thing. In Android databases are SQLite. You can read this official Android documentation about Saving Data in SQL Databases[^]. You will be able to find other resources, such as extracting and updating the data along with that document.
Finally, remove the HttpClients from your application and consider using functions to extract the data from the database and show the data on screen.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
when we create custom adapter so inside this class we use a class
like
static class ViewHolder
{
TextView textview;
ImageView imageview;
}
my question is why it static because we create the object of viewholde so if we create it nonstatic then we effect on the code
|
|
|
|
|
|
when i am using toolbar the windows title show bydefult how to hide and use image inside it
|
|
|
|
|
I am writing a command-line application (to be run via adb) that among other things monitors the temperature of an Android platform (by reading the internal temperature sensor).
When the test device overheats, it displays a popup window informing me of this. I need to trap this "high temperature" indication (from a program running at the command line), and log it to the output file.
Does anyone know if there a signal in the Android Linux Kernel for a "high temperature" condition? If there is, how do I trap it?
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
|
Am a beginner in android development. I have created one project its running only on lollipop device but not in lower versions of android while am trying to run in lower versions the app get stopped don't know what is the reason ?
It need my app to be run on all devices.What should i do to solve this issue ? Give me your suggestions.
Thank you in advance.
my logcat show this while running in lower android device
<pre>08-13 10:40:47.770 26187-26187/com.sentientit.theiWedplanner E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sentientit.theiWedplanner/com.sentientit.theiWedplanner.Frontpage}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:1930)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:50)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.sentientit.theiWedplanner.Fragadmob: make sure class name exists, is public, and has an empty constructor that is public
at android.app.Fragment.instantiate(Fragment.java:592)
at android.app.Fragment.instantiate(Fragment.java:560)
at android.app.Activity.onCreateView(Activity.java:4864)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:686)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:1930)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:50)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sentientit.theiWedplanner.Fragadmob" on path: /system/framework/com.google.android.maps.jar:/data/app/com.sentientit.theiWedplanner-2.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Fragment.instantiate(Fragment.java:582)
at android.app.Fragment.instantiate(Fragment.java:560)
at android.app.Activity.onCreateView(Activity.java:4864)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:686)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:350)
at android.app.Activity.setContentView(Activity.java:1930)
at com.sentientit.theiWedplanner.Frontpage.onCreate(Frontpage.java:50)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)</pre>
|
|
|
|
|
I am not sure why this is not thrown on other frameworks, but
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sentientit.theiWedplanner.Fragadmob" on path:
tells that the class was not found. I would suggest that you try to look into the API of that library. They would hold the answer for your problem as why is this causing a problem.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
You should look more closely at the error messages:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sentientit.theiWedplanner.Fragadmob" on path: /system/framework/com.google.android.maps.jar:/data/app/com.sentientit.theiWedplanner-2.apk
|
|
|
|
|
|
All you have given us is an error message, but no context. So it is not possible to tell where in your application the problem arises.
|
|
|
|
|
Use the debugger (to step through each line of code).
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
As you said its running on Lollipop,but not in lower version.You should check gradle.app file firstly and should change minsdk version as your choice.Hope this will help.
|
|
|
|
|
How can we create a Draggable Button in Xamarin.Android?
I tried many times, I created a simple view which ca be dragged. But i can't implement touch event to that view.
How can i do this ?
Any Idea !
Thanks in Advance
Vaikesh K P
.NET\XAMARIN DEVELOPER
Kochi - India
|
|
|
|
|
|
Here is my logcat:
08-11 13:40:18.540 15571-15571/com.test E/SQLiteLog﹕ (1) no such table: mydb
08-11 13:40:18.547 15571-15571/com.test E/SQLiteDatabase﹕ Error inserting name=abc dates=2015-08-11 01:39:56 mobno=12344553mailid=abc@abc.com bday=2/2/4341
android.database.sqlite.SQLiteException: no such table: mydb (code 1): , while compiling: INSERT INTO mydb(name,dates,mobno,mailid,bday) VALUES (?,?,?,?,?)
Here is my DatabaseHelper.java file
package com.test;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.sql.SQLException;
public class DatabaseHelper {
public static final String KEY_ROWID="_id";
public static final String KEY_NAME="name";
public static final String KEY_BDAY="bday";
public static final String KEY_MOBNO="mobno";
public static final String KEY_MAIL="mailid";
public static final String KEY_DATE="dates";
private static final String DATABASE_NAME="mydb";
private static final String DATABASE_TABLE="mytable";
private static final int DATABASE_VERSION=1;
private DbHelper ourhelper;
private Context ourcontext;
private SQLiteDatabase ourdatabase;
public DatabaseHelper(Context c){
ourcontext=c;
}
public DatabaseHelper open() throws SQLException{
ourhelper = new DbHelper(ourcontext);
ourdatabase= ourhelper.getWritableDatabase();
return this;
}
public long createentry(String name, String bday, String mobno, String mail, String dater) {
ContentValues cv=new ContentValues();
cv.put(KEY_NAME,name);
cv.put(KEY_BDAY,bday);
cv.put(KEY_MOBNO,mobno);
cv.put(KEY_MAIL, mail);
cv.put(KEY_DATE, dater);
return ourdatabase.insert(DATABASE_NAME,null,cv);
}
public void close() {
ourhelper.close();
}
public String getdata() {
String[] columns=new String[]{KEY_NAME,KEY_BDAY,KEY_MOBNO,KEY_MAIL,KEY_DATE};
Cursor c=ourdatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
String result="";
int iName= c.getColumnIndex(KEY_NAME);
int iBday= c.getColumnIndex(KEY_BDAY);
int iMob= c.getColumnIndex(KEY_MOBNO);
int iMail= c.getColumnIndex(KEY_MAIL);
int iDate= c.getColumnIndex(KEY_DATE);
for (c.moveToFirst();c.isAfterLast();c.moveToNext()){
result= result +c.getString(iName) +" "+c.getString(iBday) +" "+
c.getString(iMob)+" "+c.getString(iMail)+" "+c.getString(iDate)+
"\n";
}
return result;
}
private static class DbHelper extends SQLiteOpenHelper{
public DbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + DATABASE_TABLE +" (" +
KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " TEXT NOT NULL, " +
KEY_BDAY + " TEXT NOT NULL, " +
KEY_MOBNO + " TEXT NOT NULL, " +
KEY_MAIL + " TEXT NOT NULL, " +
KEY_DATE + " TEXT NOT NULL);"
);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
onCreate(db);
}
}
}
And here is My form.java in which Button executes following code in Onclicklistener.
boolean ok=true;
try
{
String name=etname.getText().toString();
String bday=etbdate.getText().toString();
String mobno=etmobno.getText().toString();
String mail=etmailid.getText().toString();
String dater=date.toString();
DatabaseHelper entry=new DatabaseHelper(Form.this);
entry.open();
entry.createentry(name, bday, mobno, mail, dater);
entry.close();
Toast.makeText(getApplicationContext(), "Database Uploaded ", Toast.LENGTH_LONG).show();
}
catch(Exception ex)
{
ok=false;
catcherror(ex.toString());
}
modified 28-May-24 10:56am.
|
|
|
|
|
return ourdatabase.insert(DATABASE_NAME,null,cv);
That is the name of your database, not the table it contains.
|
|
|
|
|
dear expert,
as my question in my subject, I can't change the default color of the action bar and I'm following the android documentation and I understand how it works because I have changed the background color in the main content but in the action bar its not working..
I'm using an ecplise ide and have installed the latest SDK for android which is 5.1.1
modified 10-Aug-15 3:26am.
|
|
|
|
|
Member 11897566 wrote: its not working You need to explain what that actually means. We cannot guess what you have done, or what results you see.
|
|
|
|
|
what I mean by not working is that its not taking effect when I run in on my device, and I don't have any errors in the logcat window or any. but when I change the background color of the main content or inside the linear layout for ex. and run on my device and it does take effect it changed the background color.
I use the theme.holo.light. and the way I code it like this.
in the style.XML inside resource tag
<item name="android:background">#rrggbb color code</item
|
|
|
|
|
|
Hi all, I have a TableLayout nested within a ScrollView / LinearLayout, I add rows to the table dynamically when the application starts, the problem I have is I'm only seeing a third of my tables rows e.g. if I have 30 rows I can only scroll down to row 10 - my layout is as shown below - can anyone see anything wrong with this layout ? It displays and works perfectly for the rows that are visible ( please excuse the formatting )
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tablelayoutmain"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="20dp"
android:gravity="fill">
</TableLayout>
</LinearLayout>
</ScrollView>
We can’t stop here, this is bat country - Hunter S Thompson RIP
modified 25-Jul-15 5:29am.
|
|
|
|
|
I just tried using that exact layout, with a dynamically filled table of 40 rows each of 5 columns, and it scrolls fine top to bottom. Maybe you need to show us something more.
|
|
|
|
|
Hi Richard, thanks for replying - I should have said I'm adding ListViews to my table rows which I've read are problematic in ScrollViews but if it works for ten rows it should work ( to my mind ) with any amount
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|