function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nirmal VasanthakumarNirmal Vasanthakumar 

Using smartstore in salesforce android native app facing some issues.

The scenario is like this. I am using salesForceAndroid SDK for developing an app. I am using SmartStore offered by salesforce for offline data saving purpose. Now i log in to sales force and fetch data from server and save to DB while online. Now this works fine. Now I just click the home button of android device  and take settings and clear the application data. Now the whole data is needed to be cleared like table contents, preferences etc.Now when I get back to my app, The app shows like there is still an account existing but when tried to get the restClient for that app ,

that is when calling the function peekRestClient()  in the library , a decryption error a bad padding exception is thrown. and  the app exits... Then relaunch automatically and login page is displayed. Usually clear data should clear all user data and we should be taken to login page staright away. But this is not happening. Anybody please help with this.

 

String accountType = ForceApp.APP.getAccountType();
apiVersion = activity.getResources().getString(R.string.api_version);
LoginOptions loginOptions = new LoginOptions(null,
ForceApp.APP.getPasscodeHash(), activity.getResources()
.getString(R.string.oauth_callback_url), activity
.getResources().getString(R.string.oauth_client_id),
new String[] { "api" });

new ClientManager(activity, accountType, loginOptions,
ForceApp.APP.shouldLogoutWhenTokenRevoked()).getRestClient(
activity, new RestClientCallback() {

@Override
public void authenticatedRestClient(RestClient client) {
if (client == null) {
ForceApp.APP.logout(activity);
return;
}

}
});
registerReceiver();
}

This is the code I use to login to salseForce from my app. Now when I use this normally there is no problem. Issue occurs when I clear all app data from settings. Then the app go through this processes, then when creating new ClientManager object  we have this line ForceApp.APP.shouldLogoutWhenTokenRevoked()).getRestClient(
activity, new RestClientCallback() {}  . 

In this getRestClient will take us to The function inside Clientmanager.  Now since account manager datas are not getting cleared while we are doing app data clear from settings, getOauthToken functoin is called which has got a call back AccMgrCallback  

From there to get the client object we call peekRestClient() 

There to generate oauthToken we need to do a decryption. There is where I am getting a bad padding exceptoin and decryptoin error. This leads to log out and we are taken to login page.  Also when I log in and try  to save data to soup then a smartstoreexception is thrown saying table does not have an index on the specified path. This seems like after deleting db  the index map table is not restored. What could be the possible solution for this behaviour on clearing app data.

Gaurav KheterpalGaurav Kheterpal

Can you share your code snippet?

Nirmal VasanthakumarNirmal Vasanthakumar

I have added the code and issue in details above with my question. could you please check that and suggest a possible answer.

bhariharanbhariharan

This has been resolved in our latest release (2.0.1). Please upgrade to the latest and check if that fixes your issue and mark this as resolved if so.