android - transferring JSON file's data into SQLite -


i've written short program transfer data json file sqlite file, , although i'm not getting errors , it's isn't working.

my goal build app have default sqlite db file app load on startup. since have around 10k records , instead of creating them program , doing "insert" 10k times - created sqlite file. needed somehow initialize db file. wrote short program that. takes json file , parses , saves on db file. seems me contentvalues object null though override key-value pair multiple times.

the code :

    public class jsontodb {     static void transfer( weakreference<context> context )     {         databaseloader.init( context );         string column_password = "password";         string column_count = "success_count";          contentvalues cv = new contentvalues();         jsonparser parser = new jsonparser();          try          {             object obj = parser.parse( new filereader(                     "/users/user/downloads/convert.json" ) );              jsonarray jsonarray = (jsonarray) obj;             (int i=0 ; i<jsonarray.length() ; i++){                 string password = (string) jsonarray.getjsonobject( ).get( "code" );                 integer countint =  (integer) jsonarray.getjsonobject( ).get( "count" );                 int count = countint.intvalue();                 cv.put( "password" ,password );                  cv.put( "success_count" , count );                 databaseloader.getinstance().transferjson( cv );             }            }             catch( exception e )         {             log.d( "tag", "not working" );         }      } } 

the code in database helper :

public void transferjson( contentvalues cv )     {         string table_passwords = "passwords";         try         {             getdb().insert( table_passwords, null, cv );         }         catch( sqliteexception erroropeningdb )         {             log.e( error_open_file_tag, "problem" ,erroropeningdb );         } 

then "problem" log.

thank much.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -