android - How to store data from website to parse.com And how to to fetch data of it in my application -


i want use parse database developing web app, since data upload desktop pc , retreival of same done in parse mobile application.

is possible use parse database website backend ?

since want use same parse database application , desktop version.

can please me, providing idea how achieve that?

thanks in advance.

is possible use parse database website backend ? 

yes, possible: .net guide, rest api

since want use same parse database application , desktop version. 

yes, can use same database application , desktop version.


for store data using android create object like:

parseobject gamescore = new parseobject("gamescore"); gamescore.put("score", 1337); gamescore.put("playername", "sean plott"); gamescore.put("cheatmode", false); gamescore.saveinbackground(); 

above code create table in parse.com(database automatically created when store data using object.) check dashboard: below image

enter image description here

for fetch data try way:

parsequery query = new parsequery("gamescore"); query.getinbackground("xwmyz4yegz", new getcallback() {   public void done(parseobject object, parseexception e) {     if (e == null) {       // object game score     } else {       // went wrong     }   } }); 

same way can use web application desktop application (rest api)


for create table user have create object like:

parseobject gamescore = new parseobject("user");     gamescore.put("first name", "dhaval");     gamescore.put("last name", "sodha");     gamescore.put("email", "xyz@gmail.com");     gamescore.put("phone", "9876543210");     gamescore.put("address", "xyz");     gamescore.put("city", "ahmedabad");     gamescore.put("country", "india");     gamescore.saveinbackground(); 

above object ll create table fields(id ,first name, last name, email, phone, address, city, ... time, created...etc )


edited:


get data (select * user city = 'ahmedabad' , country = 'india')

           parsequery lotsofwins = new parsequery("user");             lotsofwins.whereequalto("city", "ahmedabad");              parsequery fewwins = new parsequery("user");             fewwins.whereequalto("country", "india");              list<parsequery> queries = new arraylist<parsequery>();             queries.add(lotsofwins);             queries.add(fewwins);              parsequery mainquery = parsequery.or(queries);             mainquery.findinbackground(new findcallback() {             public void done(list<parseobject> scorelist, parseexception e) {                 if (e == null) {                     log.d("score", "retrieved " + scorelist.size() + " scores");                     // here size 0 'no data found!'                 } else {                     log.d("score", "error: " + e.getmessage());                 }             } 

here: public void done(list<parseobject> scorelist, parseexception e) result in object

list<parseobject>: list of object return query.

parseexception: exception if occur..

so, scorelist.size() give total size of object return query.

how fetch data:

string username = scorelist.getstring("username"); 

how save file: (whatever mime type png,jpg,doc,txt....etc)its works all

upload file using below code:

bytearrayoutputstream stream = new bytearrayoutputstream();                 userimage.compress(bitmap.compressformat.png, 100, stream);                 byte[] bytearray = stream.tobytearray();                 string usetphoto = "user"+system.currenttimemillis()+"image";                 parsefile file = new parsefile(usetphoto, bytearray);                  parseobject gamescore = new parseobject("userdetails");                 gamescore.put("username", "" + username.gettext().tostring());                 gamescore.put("userphoto", "" + file);                 gamescore.saveinbackground(); 

retrive file parse api using above object:

parsefile applicantresume = (parsefile)gamescore.get("userphoto");             applicantresume.getdatainbackground(new getdatacallback() {               public void done(byte[] data, parseexception e) {                 if (e == null) {                   // data has bytes resume                 } else {                   // went wrong                 }               }             }); 

here get: public void done(byte[] data, parseexception e)

byte[] : byte[] of file(whatever file type - if have uploaded png save byte png).

parseexception : exception if occur..


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -