0

I am working in android app project in which I am storing data into a local db which is sqlite for store data offline.Data size is minimal which is basically like name,mobile no etc.I store those data into sqlite because i consider that app client don't have internet connection or he store multiple data so he can store data locally,and the next part is send data into a sql server with a button click.I can't work with synchronization because of sql server (Central remote server) have lot's of table and lot's data,i don't want to rush my local android app db.I am tryed to fetch data with while loop and then fetch data from sqlite and then send data sql server directly(i don't use api because security is not a concern here)

enter code here

package com.ohnnu.myofficetool;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by joy on 11/4/2016.
 */

public class DatabaseHelper extends SQLiteOpenHelper {


    public static final String DATABASE_NAME="myofficetool.db";
    public static final String TABLE_NAME="orderChalan_table";
    public static final String COL_1="ID";
    public static final String COL_2="ProdNo";
    public static final String COL_3="Qtn";
    public static final String COL_4="CusID";
    public String delete;

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);

    }


    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("create table "+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT,ProdNo TEXT,Qtn TEXT,CusID TEXT)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
        onCreate(db);

    }

    }
    public Cursor getAllData(){
        SQLiteDatabase db=this.getWritableDatabase();
        Cursor res=db.rawQuery("select * from "+TABLE_NAME,null);
        return res;
    }

}

What i am trying now to fetch information in asynctask after that send the fetch data into sql server.Please suggest me how to fetch information in aynctask,

2
  • the big question... are you planing to do any CRUD transaction offline?? Commented Nov 5, 2016 at 13:40
  • Yes, doing a one way synch isn't too bad, but if your app is to allow editing of the data, synchronising and reconciling the database changes later can be challenging Commented Nov 5, 2016 at 13:50

1 Answer 1

1

you need to use webservices to send data to webserver.

Sign up to request clarification or add additional context in comments.

4 Comments

Yes i can make a web service to send data web server but in this scenario I don't consider security matter, a few clients will use this app so i am trying to send data directly from android app (After fetch from sqlite).
I find something which may be fit for what i am looking for, I will update here after do some research codeofaninja.com/2013/12/…
ok thats good but i thing directly data sending is not possible
try { Class.forName("net.sourceforge.jtds.jdbc.Driver"); ConnectionURL = "jdbc:jtds:sqlserver://your ip;DatabaseName=your database;user=your username;password=your password"; connection = DriverManager.getConnection(ConnectionURL); } catch (SQLException se) { Log.e("error here 1 : ", se.getMessage()); } execute code under a class,after that initiate the class pass parameters perform query , I hope i make myself clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.