Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:11:08+00:00 2026-06-01T12:11:08+00:00

@Override public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE); // providers data // db.execSQL(insert into //

  • 0
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);
        // providers data
//      db.execSQL("insert  into "
//              + TABLE_PROVIDERS
//              + " (_id, provider_id, parent_id, title, image, sh_n, enable, visible, image_bg, type, is_group, hide_in_search, limit_min, limit_max, off_on_line, invoice_search) "
//              + "VALUES (1,600,101,'Источники оплаты','',1,1,0,'','',1,1,0,0,0,0)");

        ContentValues cv = new ContentValues();
        cv.put("_id", 1);
        cv.put("provider_id", 600);
        cv.put("parent_id", 101);
        cv.put("title", "Bla");
        cv.put("image", "bla");
        cv.put("sh_n", 1);
        cv.put("enable", 1);
        cv.put("visible", 1);
        cv.put("image_bg", "");
        cv.put("type", "");
        cv.put("is_group", 1);
        cv.put("hide_in_search", 1);
        cv.put("limit_min", 10);
        cv.put("limit_max", 10000);
        cv.put("off_on_line", 1);
        cv.put("invoice_search", 1);

        db.insertOrThrow(TABLE_PROVIDERS, null, cv);
}

Now I’m doing as was suggested, inserting row by row:

import java.util.*;

import android.content.*;
import android.database.*;
import android.database.sqlite.*;

public class ProviderDataSource {

    private SQLiteDatabase database;
    private MySQLiteHelper dbHelper;

    public ProviderDataSource(Context context) {
        dbHelper = new MySQLiteHelper(context);
    }

    public void open() throws SQLException {
        database = dbHelper.getWritableDatabase();
    }

    public void close() {
        dbHelper.close();
    }

    public List<Provider> getProvidersByParentId(long parentId) {

        List<Provider> providersList = new ArrayList<Provider>();

        Cursor cursor = database.query(MySQLiteHelper.TABLE_PROVIDERS, new String[] { "provider_id", "title", "image" }, " parent_id=" + parentId,
                null, null, null, null);

        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            Provider provider = cursorToProvider(cursor);
            providersList.add(provider);
            cursor.moveToNext();
        }
        cursor.close();
        System.out.println("getProvidersByParentId");
        return providersList;
    }

    private Provider cursorToProvider(Cursor cursor) {

        Provider provider = new Provider();
        provider.setId(cursor.getInt(1));
        provider.setTitle(cursor.getString(3));
        provider.setImg(cursor.getString(4));

        return provider;

    }

}

It doesn’t work. It seems like the row wasn`t inserted and the array returnd by getProvidersByParentId method is empty. Parent_id as argument is 101.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:11:09+00:00Added an answer on June 1, 2026 at 12:11 pm

    Your insert statement is wrong. In SQLite, you cant insert multiple records by separating them with comma, in fact you need to prepare separate insert commands for that. But if your SQLite version is 3.7.11 then its possible.

    Read this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I make a database with four columns. @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE
I draw an arc using onDraw(canvas) : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
I'm creating a new database in my Activity like this: @Override public void onCreate(Bundle
@Override public void onCancel() { // TODO Auto-generated method stub ERROR:The method onCancel() of
I have this code: @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { GLES20.glClearColor(0, 0,
this is my thread: @Override public void run() { Log.d(ConnectionThread,Starting Server Connection); try {
public class CursorAtStartFocusListener extends FocusAdapter { @Override public void focusGained(java.awt.event.FocusEvent evt) { Object source
Thread thread = new Thread(new Runnable() { @Override public void run() { try {
In a WebView-derived class I override loadUrl(): @Override public void loadUrl(String url) { super.loadUrl(url);
In facebook tutorials I see this sample code: @Override public void onActivityResult(int requestCode, int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.